Commit e8b1b59dc8e42a47c4ce541bd1767ffac206b29c

Authored by Wei Yongjun
Committed by Len Brown
1 parent f5a246eab9

cpuidle / ACPI: fix potential NULL pointer dereference

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>

Showing 1 changed file with 2 additions and 1 deletions Side-by-side Diff

drivers/acpi/processor_idle.c
... ... @@ -1132,7 +1132,7 @@
1132 1132 int acpi_processor_hotplug(struct acpi_processor *pr)
1133 1133 {
1134 1134 int ret = 0;
1135   - struct cpuidle_device *dev = per_cpu(acpi_cpuidle_device, pr->id);
  1135 + struct cpuidle_device *dev;
1136 1136  
1137 1137 if (disabled_by_idle_boot_param())
1138 1138 return 0;
... ... @@ -1147,6 +1147,7 @@
1147 1147 if (!pr->flags.power_setup_done)
1148 1148 return -ENODEV;
1149 1149  
  1150 + dev = per_cpu(acpi_cpuidle_device, pr->id);
1150 1151 cpuidle_pause_and_lock();
1151 1152 cpuidle_disable_device(dev);
1152 1153 acpi_processor_get_power_info(pr);