aboutsummaryrefslogtreecommitdiff
path: root/drivers/cpufreq/cpufreq_stats.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2005-11-07 13:28:20 -0800
committerLinus Torvalds <torvalds@g5.osdl.org>2005-11-07 13:28:20 -0800
commitdad2ad82c5f058367df79de022bd12d36afcd065 (patch)
tree426a1a6ca8762356b375527768bedc2de0bd25e9 /drivers/cpufreq/cpufreq_stats.c
parent7079060f3e86ea4c1d4e9c1e356592ef9dcaaa1f (diff)
parentb7fb358c7c36a14927d5523ea674e69f90c51d1d (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/davej/cpufreq
Diffstat (limited to 'drivers/cpufreq/cpufreq_stats.c')
-rw-r--r--drivers/cpufreq/cpufreq_stats.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
index 3597f25d5ef..0bddb8e694d 100644
--- a/drivers/cpufreq/cpufreq_stats.c
+++ b/drivers/cpufreq/cpufreq_stats.c
@@ -193,11 +193,15 @@ cpufreq_stats_create_table (struct cpufreq_policy *policy,
unsigned int cpu = policy->cpu;
if (cpufreq_stats_table[cpu])
return -EBUSY;
- if ((stat = kmalloc(sizeof(struct cpufreq_stats), GFP_KERNEL)) == NULL)
+ if ((stat = kzalloc(sizeof(struct cpufreq_stats), GFP_KERNEL)) == NULL)
return -ENOMEM;
- memset(stat, 0, sizeof (struct cpufreq_stats));
data = cpufreq_cpu_get(cpu);
+ if (data == NULL) {
+ ret = -EINVAL;
+ goto error_get_fail;
+ }
+
if ((ret = sysfs_create_group(&data->kobj, &stats_attr_group)))
goto error_out;
@@ -217,12 +221,11 @@ cpufreq_stats_create_table (struct cpufreq_policy *policy,
alloc_size += count * count * sizeof(int);
#endif
stat->max_state = count;
- stat->time_in_state = kmalloc(alloc_size, GFP_KERNEL);
+ stat->time_in_state = kzalloc(alloc_size, GFP_KERNEL);
if (!stat->time_in_state) {
ret = -ENOMEM;
goto error_out;
}
- memset(stat->time_in_state, 0, alloc_size);
stat->freq_table = (unsigned int *)(stat->time_in_state + count);
#ifdef CONFIG_CPU_FREQ_STAT_DETAILS
@@ -245,6 +248,7 @@ cpufreq_stats_create_table (struct cpufreq_policy *policy,
return 0;
error_out:
cpufreq_cpu_put(data);
+error_get_fail:
kfree(stat);
cpufreq_stats_table[cpu] = NULL;
return ret;