i2c_hid: add some NULL checks
Apparently, ACPI string attributes can exist but be NULL. Fixes a crash on boot when the driver is enabled on my Chromebook. Change-Id: I11a56eec5d86b7e348cbffb305270732633e7390 Reviewed-on: https://review.haiku-os.org/c/haiku/+/10924 Reviewed-by: waddlesplash <[email protected]> Tested-by: Commit checker robot <[email protected]>
This commit is contained in:
committed by
Adrien Destugues
parent
7f2e069f93
commit
caf5c2722d
@@ -262,8 +262,8 @@ i2c_hid_support(device_node *parent)
|
|||||||
CALLED();
|
CALLED();
|
||||||
|
|
||||||
// make sure parent is really the I2C bus manager
|
// make sure parent is really the I2C bus manager
|
||||||
const char *bus;
|
const char *bus = NULL;
|
||||||
if (sDeviceManager->get_attr_string(parent, B_DEVICE_BUS, &bus, false))
|
if (sDeviceManager->get_attr_string(parent, B_DEVICE_BUS, &bus, false) != B_OK)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (strcmp(bus, "i2c"))
|
if (strcmp(bus, "i2c"))
|
||||||
@@ -280,13 +280,13 @@ i2c_hid_support(device_node *parent)
|
|||||||
|
|
||||||
const char *name;
|
const char *name;
|
||||||
if (sDeviceManager->get_attr_string(parent, ACPI_DEVICE_HID_ITEM, &name,
|
if (sDeviceManager->get_attr_string(parent, ACPI_DEVICE_HID_ITEM, &name,
|
||||||
false) == B_OK && strcmp(name, ACPI_NAME_HID_DEVICE) == 0) {
|
false) == B_OK && name != NULL && strcmp(name, ACPI_NAME_HID_DEVICE) == 0) {
|
||||||
TRACE("i2c_hid_support found an hid i2c device\n");
|
TRACE("i2c_hid_support found an hid i2c device\n");
|
||||||
return 0.6;
|
return 0.6;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sDeviceManager->get_attr_string(parent, ACPI_DEVICE_CID_ITEM, &name,
|
if (sDeviceManager->get_attr_string(parent, ACPI_DEVICE_CID_ITEM, &name,
|
||||||
false) == B_OK && strcmp(name, ACPI_NAME_HID_DEVICE) == 0) {
|
false) == B_OK && name != NULL && strcmp(name, ACPI_NAME_HID_DEVICE) == 0) {
|
||||||
TRACE("i2c_hid_support found a compatible hid i2c device\n");
|
TRACE("i2c_hid_support found a compatible hid i2c device\n");
|
||||||
return 0.6;
|
return 0.6;
|
||||||
}
|
}
|
||||||
@@ -474,13 +474,15 @@ driver_module_info i2c_hid_driver_module = {
|
|||||||
&std_ops
|
&std_ops
|
||||||
},
|
},
|
||||||
|
|
||||||
i2c_hid_support,
|
.supports_device = i2c_hid_support,
|
||||||
i2c_hid_register_device,
|
.register_device = i2c_hid_register_device,
|
||||||
i2c_hid_init_driver,
|
.init_driver = i2c_hid_init_driver,
|
||||||
i2c_hid_uninit_driver,
|
.uninit_driver = i2c_hid_uninit_driver,
|
||||||
i2c_hid_register_child_devices,
|
.register_child_devices = i2c_hid_register_child_devices,
|
||||||
NULL, // rescan
|
.rescan_child_devices = NULL,
|
||||||
NULL, // removed
|
.device_removed = NULL,
|
||||||
|
.suspend = NULL,
|
||||||
|
.resume = NULL,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user