提交 51e3c1b5 编写于 作者: S Sergey Senozhatsky 提交者: H. Peter Anvin

x86, hwmon: Fix unsafe smp_processor_id() in thermal_throttle_add_dev

Fix BUG: using smp_processor_id() in preemptible thermal_throttle_add_dev.
We know the cpu number when calling thermal_throttle_add_dev, so we can
remove smp_processor_id call in thermal_throttle_add_dev by supplying
the cpu number as argument.

This should resolve kernel bugzilla 16615/16629.
Signed-off-by: NSergey Senozhatsky <sergey.senozhatsky@gmail.com>
LKML-Reference: <20100820073634.GB5209@swordfish.minsk.epam.com>
Cc: Fenghua Yu <fenghua.yu@intel.com>
Cc: Joerg Roedel <Joerg.Roedel@amd.com>
Cc: Maciej Rutecki <maciej.rutecki@gmail.com>
Signed-off-by: NH. Peter Anvin <hpa@zytor.com>
上级 36423a5e
...@@ -202,10 +202,11 @@ static int therm_throt_process(bool new_event, int event, int level) ...@@ -202,10 +202,11 @@ static int therm_throt_process(bool new_event, int event, int level)
#ifdef CONFIG_SYSFS #ifdef CONFIG_SYSFS
/* Add/Remove thermal_throttle interface for CPU device: */ /* Add/Remove thermal_throttle interface for CPU device: */
static __cpuinit int thermal_throttle_add_dev(struct sys_device *sys_dev) static __cpuinit int thermal_throttle_add_dev(struct sys_device *sys_dev,
unsigned int cpu)
{ {
int err; int err;
struct cpuinfo_x86 *c = &cpu_data(smp_processor_id()); struct cpuinfo_x86 *c = &cpu_data(cpu);
err = sysfs_create_group(&sys_dev->kobj, &thermal_attr_group); err = sysfs_create_group(&sys_dev->kobj, &thermal_attr_group);
if (err) if (err)
...@@ -251,7 +252,7 @@ thermal_throttle_cpu_callback(struct notifier_block *nfb, ...@@ -251,7 +252,7 @@ thermal_throttle_cpu_callback(struct notifier_block *nfb,
case CPU_UP_PREPARE: case CPU_UP_PREPARE:
case CPU_UP_PREPARE_FROZEN: case CPU_UP_PREPARE_FROZEN:
mutex_lock(&therm_cpu_lock); mutex_lock(&therm_cpu_lock);
err = thermal_throttle_add_dev(sys_dev); err = thermal_throttle_add_dev(sys_dev, cpu);
mutex_unlock(&therm_cpu_lock); mutex_unlock(&therm_cpu_lock);
WARN_ON(err); WARN_ON(err);
break; break;
...@@ -287,7 +288,7 @@ static __init int thermal_throttle_init_device(void) ...@@ -287,7 +288,7 @@ static __init int thermal_throttle_init_device(void)
#endif #endif
/* connect live CPUs to sysfs */ /* connect live CPUs to sysfs */
for_each_online_cpu(cpu) { for_each_online_cpu(cpu) {
err = thermal_throttle_add_dev(get_cpu_sysdev(cpu)); err = thermal_throttle_add_dev(get_cpu_sysdev(cpu), cpu);
WARN_ON(err); WARN_ON(err);
} }
#ifdef CONFIG_HOTPLUG_CPU #ifdef CONFIG_HOTPLUG_CPU
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册