platform/x86: wmi: fix potential null pointer dereference
authorMattias Jacobsson <2pi@mok.nu>
Wed, 30 Jan 2019 15:14:24 +0000 (16:14 +0100)
committerDarren Hart (VMware) <dvhart@infradead.org>
Sat, 23 Feb 2019 17:20:29 +0000 (09:20 -0800)
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.

Fixes: 844af950da94 ("platform/x86: wmi: Turn WMI into a bus driver")
Signed-off-by: Mattias Jacobsson <2pi@mok.nu>
Signed-off-by: Darren Hart (VMware) <dvhart@infradead.org>
drivers/platform/x86/wmi.c

index bea35be68706d733cf156b993fe0a8b3d3a675e5..b0f3d8ecd898c7c8def008be9be0a2e941511d64 100644 (file)
@@ -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;