]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
platform/chrome: wilco_ec: event: Check ACPI_COMPANION()
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 12 May 2026 16:36:42 +0000 (18:36 +0200)
committerTzung-Bi Shih <tzungbi@kernel.org>
Wed, 13 May 2026 02:19:46 +0000 (02:19 +0000)
Every platform driver can be forced to match a device that doesn't match
its list of device IDs because of device_match_driver_override(), so
platform drivers that rely on the existence of a device's ACPI companion
object need to verify its presence.

Accordingly, add a requisite ACPI_COMPANION() check against NULL to the
wilco_ec event driver.

Fixes: 27d58498f690 ("platform/chrome: wilco_ec: event: Convert to a platform driver")
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://lore.kernel.org/r/2076666.usQuhbGJ8B@rafael.j.wysocki
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
drivers/platform/chrome/wilco_ec/event.c

index b6e935badc0e94e8201d1eea6125c164f45a68e6..1b5cb89839e084b99d68e84f6470b36b233070d5 100644 (file)
@@ -452,8 +452,13 @@ static void hangup_device(struct event_device_data *dev_data)
 static int event_device_probe(struct platform_device *pdev)
 {
        struct event_device_data *dev_data;
+       struct acpi_device *adev;
        int error, minor;
 
+       adev = ACPI_COMPANION(&pdev->dev);
+       if (!adev)
+               return -ENODEV;
+
        minor = ida_alloc_max(&event_ida, EVENT_MAX_DEV-1, GFP_KERNEL);
        if (minor < 0) {
                error = minor;
@@ -494,8 +499,7 @@ static int event_device_probe(struct platform_device *pdev)
                goto free_dev_data;
 
        /* Install an ACPI notify handler. */
-       error = acpi_dev_install_notify_handler(ACPI_COMPANION(&pdev->dev),
-                                               ACPI_DEVICE_NOTIFY,
+       error = acpi_dev_install_notify_handler(adev, ACPI_DEVICE_NOTIFY,
                                                event_device_notify, &pdev->dev);
        if (error)
                goto free_cdev;