]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
sonypi: Check ACPI_COMPANION() against NULL at probe time
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 12 May 2026 16:20:53 +0000 (18:20 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 23 May 2026 11:47:34 +0000 (13:47 +0200)
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
sonypi driver.

Fixes: 7e488b0af021 ("sonypi: Convert ACPI driver to a platform one")
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Link: https://patch.msgid.link/5087721.GXAFRqVoOG@rafael.j.wysocki
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/char/sonypi.c

index ccda997a9098a32d8207e7c5436db9ae0836494d..24c1b26f34d6b1c8bf7b3bae5f086550a9d00519 100644 (file)
@@ -1117,7 +1117,11 @@ static int sonypi_disable(void)
 #ifdef CONFIG_ACPI
 static int sonypi_acpi_probe(struct platform_device *pdev)
 {
-       struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
+       struct acpi_device *device;
+
+       device = ACPI_COMPANION(&pdev->dev);
+       if (!device)
+               return -ENODEV;
 
        sonypi_acpi_device = device;
        strcpy(acpi_device_name(device), "Sony laptop hotkeys");