platform/x86: wmi: fix potential null pointer dereference
PATCH v2 1/1 platform/x86: wmi: fix potential null pointer dereference
In the function wmi_dev_match() the variable id is dereferenced without first performing a NULL check. The variable can for example be NULL if a WMI driver is registered without specifying the id_table field in struct wmi_driver.
Add a NULL check and return that the driver can't handle the device if the variable is NULL.
--- drivers/platform/x86/wmi.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/platform/x86/wmi.c +3 -0
@@ -768,6 +768,9 @@ static int wmi_dev_match(struct device *dev, struct device_driver *driver)struct wmi_block *wblock =dev_to_wblock (dev);const struct wmi_device_id *id = wmi_driver->id_table; +if (id ==NULL ) +return 0 ; +while (id->guid_string) {uuid_le driver_guid;
Signature · 1 line
2.20.1
Quoted 9 lines · Mattias Jacobsson
In the function
wmi_dev_match()the variable id is dereferenced without first performing a NULL check. The variable can for example be NULL if a WMI driver is registered without specifying theid_tablefield in structwmi_driver.Add a NULL check and return that the driver can't handle the device if the variable is NULL.
Good for me, thanks!
Quoted 23 lines
Fixes 844af950da94 ("platform/x86: wmi: Turn WMI into a bus driver")Signed-off-by Mattias Jacobsson <[email protected]>--- drivers/platform/x86/wmi.c | 3 +++ 1 file changed, 3 insertions(+)drivers/platform/x86/wmi.c +3
-1@@ -768,6 +768,9 @@ static int wmi_dev_match(struct device *dev, struct device_driver *driver)struct wmi_block *wblock =dev_to_wblock (dev);const struct wmi_device_id *id = wmi_driver->id_table; +if (id ==NULL ) +return 0 ; +while (id->guid_string) {uuid_le driver_guid; --2.20.1
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 7 lines · Andy Shevchenko
Quoted 6 lines · Mattias Jacobsson
In the function
wmi_dev_match()the variable id is dereferenced without first performing a NULL check. The variable can for example be NULL if a WMI driver is registered without specifying theid_tablefield in structwmi_driver.
Quoted 5 lines
Quoted 3 lines
Add a NULL check and return that the driver can't handle the device if the variable is NULL.
Good for me, thanks!
Queued for testing, thanks Mattias.
Signature · 2 lines
Darren Hart VMware Open Source Technology Center