]> Pileus Git - ~andy/linux/commitdiff
cpuidle / ACPI: fix potential NULL pointer dereference
authorWei Yongjun <yongjun_wei@trendmicro.com.cn>
Mon, 8 Oct 2012 00:40:42 +0000 (08:40 +0800)
committerLen Brown <len.brown@intel.com>
Tue, 9 Oct 2012 02:51:27 +0000 (22:51 -0400)
The dereference should be moved below the NULL test.

dpatch engine is used to auto generate this patch.
(https://github.com/weiyj/dpatch)

Signed-off-by: Wei Yongjun <yongjun_wei@trendmicro.com.cn>
Signed-off-by: Len Brown <len.brown@intel.com>
drivers/acpi/processor_idle.c

index 3655ab923812c10501e86cde8b166cb18be70065..e8086c7253054bc7690f1041d6dd358156d94283 100644 (file)
@@ -1132,7 +1132,7 @@ static int acpi_processor_setup_cpuidle_states(struct acpi_processor *pr)
 int acpi_processor_hotplug(struct acpi_processor *pr)
 {
        int ret = 0;
-       struct cpuidle_device *dev = per_cpu(acpi_cpuidle_device, pr->id);
+       struct cpuidle_device *dev;
 
        if (disabled_by_idle_boot_param())
                return 0;
@@ -1147,6 +1147,7 @@ int acpi_processor_hotplug(struct acpi_processor *pr)
        if (!pr->flags.power_setup_done)
                return -ENODEV;
 
+       dev = per_cpu(acpi_cpuidle_device, pr->id);
        cpuidle_pause_and_lock();
        cpuidle_disable_device(dev);
        acpi_processor_get_power_info(pr);