]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
hpet: Check ACPI_COMPANION() against NULL at probe time
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 12 May 2026 16:20:09 +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
hpet driver.

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

index 46c84e5df00fd54d714a0fc3c29ad4d63dda4a2a..285c6037417ab2eec2a702fbb39abef4fc862235 100644 (file)
@@ -976,10 +976,14 @@ static acpi_status hpet_resources(struct acpi_resource *res, void *data)
 
 static int hpet_acpi_probe(struct platform_device *pdev)
 {
-       struct acpi_device *device = ACPI_COMPANION(&pdev->dev);
+       struct acpi_device *device;
        acpi_status result;
        struct hpet_data data;
 
+       device = ACPI_COMPANION(&pdev->dev);
+       if (!device)
+               return -ENODEV;
+
        memset(&data, 0, sizeof(data));
 
        result =