platform/x86: wmi: Check if event data is not NULL
authorArmin Wolf <W_Armin@gmx.de>
Mon, 19 Feb 2024 11:59:16 +0000 (12:59 +0100)
committerIlpo Järvinen <ilpo.jarvinen@linux.intel.com>
Tue, 27 Feb 2024 12:44:20 +0000 (14:44 +0200)
WMI event drivers which do not have no_notify_data set expect
that each WMI event contains valid data. Evaluating _WED however
might return no data, which can cause issues with such drivers.

Fix this by validating that evaluating _WED did return data.

Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Link: https://lore.kernel.org/r/20240219115919.16526-3-W_Armin@gmx.de
Reviewed-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Signed-off-by: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
drivers/platform/x86/wmi.c

index 8fb90b726f506155cff8509e9aaad4a3066e6615..ff4742c40cc3996fd4e952ee1e933e599d58092e 100644 (file)
@@ -1210,6 +1210,7 @@ static void wmi_notify_driver(struct wmi_block *wblock)
 {
        struct wmi_driver *driver = drv_to_wdrv(wblock->dev.dev.driver);
        struct acpi_buffer data = { ACPI_ALLOCATE_BUFFER, NULL };
+       union acpi_object *obj = NULL;
        acpi_status status;
 
        if (!driver->no_notify_data) {
@@ -1218,12 +1219,18 @@ static void wmi_notify_driver(struct wmi_block *wblock)
                        dev_warn(&wblock->dev.dev, "Failed to get event data\n");
                        return;
                }
+
+               obj = data.pointer;
+               if (!obj) {
+                       dev_warn(&wblock->dev.dev, "Event contains no event data\n");
+                       return;
+               }
        }
 
        if (driver->notify)
-               driver->notify(&wblock->dev, data.pointer);
+               driver->notify(&wblock->dev, obj);
 
-       kfree(data.pointer);
+       kfree(obj);
 }
 
 static int wmi_notify_device(struct device *dev, void *data)