i2c_hid: Don't crash on bogus i2c devices

Chromebook elemi has no touchscreen but coreboot still declares one in ACPI
tables. Fail gracefully rather than hard crash

Change-Id: I3bad098e7c7887e86669143c0ccec5b46b1428d4
Reviewed-on: https://review.haiku-os.org/c/haiku/+/6659
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
This commit is contained in:
Vladimir Serbinenko 2023-06-25 20:09:20 +02:00 committed by Jérôme Duval
parent 3801ec71a3
commit d1e42115d0

View File

@ -377,7 +377,7 @@ i2c_hid_init_driver(device_node *node, void **driverCookie)
mutex_unlock(&sDriverLock);
return B_OK;
return device->hidDevice != NULL ? B_OK : B_IO_ERROR;
}
@ -397,6 +397,8 @@ i2c_hid_register_child_devices(void *cookie)
CALLED();
hid_driver_cookie *device = (hid_driver_cookie*)cookie;
HIDDevice* hidDevice = device->hidDevice;
if (hidDevice == NULL)
return B_OK;
for (uint32 i = 0;; i++) {
ProtocolHandler *handler = hidDevice->ProtocolHandlerAt(i);
if (handler == NULL)