]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
ACPI: processor: idle: Fix NULL pointer dereference in hotplug path
authorHuisong Li <lihuisong@huawei.com>
Fri, 3 Apr 2026 09:02:53 +0000 (17:02 +0800)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Sat, 4 Apr 2026 18:42:37 +0000 (20:42 +0200)
A cpuidle_device might fail to register during boot, but the system can
continue to run. In such cases, acpi_processor_hotplug() can trigger
a NULL pointer dereference when accessing the per-cpu acpi_cpuidle_device.

So add NULL pointer check for the per-cpu acpi_cpuidle_device in
acpi_processor_hotplug.

Signed-off-by: Huisong Li <lihuisong@huawei.com>
Link: https://patch.msgid.link/20260403090253.998322-1-lihuisong@huawei.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/acpi/processor_idle.c

index 6172462c7b4ef65e50d4cebf2779f78f039335be..c1cddb4a5887b8fb1a4c7fa64effca378f5be132 100644 (file)
@@ -1267,16 +1267,15 @@ static int acpi_processor_get_power_info(struct acpi_processor *pr)
 
 int acpi_processor_hotplug(struct acpi_processor *pr)
 {
+       struct cpuidle_device *dev = per_cpu(acpi_cpuidle_device, pr->id);
        int ret = 0;
-       struct cpuidle_device *dev;
 
        if (disabled_by_idle_boot_param())
                return 0;
 
-       if (!pr->flags.power_setup_done)
+       if (!pr->flags.power_setup_done || !dev)
                return -ENODEV;
 
-       dev = per_cpu(acpi_cpuidle_device, pr->id);
        cpuidle_pause_and_lock();
        cpuidle_disable_device(dev);
        ret = acpi_processor_get_power_info(pr);