diff options
author | Gary King <gking@nvidia.com> | 2010-05-26 13:13:01 -0700 |
---|---|---|
committer | Gary King <gking@nvidia.com> | 2010-05-26 13:44:05 -0700 |
commit | 36dd16296ba1c2e1920241c0b3baf748e635683a (patch) | |
tree | 9da1ae02c4267c657f08020f46f8d1020e986078 /drivers/cpufreq | |
parent | f0449fc8a848601b2d0df78f4680c2f5cb222af8 (diff) |
cpufreq: check for NULL before copying governor name
if a CPU is hot-unplugged before a governor is applied to the CPU's
policy, the string copy to save off the governor's name in
__cpufreq_remove_dev (introduced in e77b89f13) will deref a NULL
pointer.
Change-Id: I7b4069c8cd4048699e7a827a3838c8653183f93b
Diffstat (limited to 'drivers/cpufreq')
-rw-r--r-- | drivers/cpufreq/cpufreq.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index ff57c40e9b8b..43350ad2dde2 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -1128,8 +1128,9 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev) #ifdef CONFIG_SMP #ifdef CONFIG_HOTPLUG_CPU - strncpy(per_cpu(cpufreq_cpu_governor, cpu), data->governor->name, - CPUFREQ_NAME_LEN); + if (data->governor) + strncpy(per_cpu(cpufreq_cpu_governor, cpu), + data->governor->name, CPUFREQ_NAME_LEN); #endif /* if we have other CPUs still registered, we need to unlink them, @@ -1153,8 +1154,9 @@ static int __cpufreq_remove_dev(struct sys_device *sys_dev) continue; dprintk("removing link for cpu %u\n", j); #ifdef CONFIG_HOTPLUG_CPU - strncpy(per_cpu(cpufreq_cpu_governor, j), - data->governor->name, CPUFREQ_NAME_LEN); + if (data->governor) + strncpy(per_cpu(cpufreq_cpu_governor, j), + data->governor->name, CPUFREQ_NAME_LEN); #endif cpu_sys_dev = get_cpu_sysdev(j); sysfs_remove_link(&cpu_sys_dev->kobj, "cpufreq"); |