diff options
Diffstat (limited to 'drivers/cpufreq/cpufreq_stats.c')
-rw-r--r-- | drivers/cpufreq/cpufreq_stats.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c index 3597f25d5efa..0bddb8e694d9 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, | |||
193 | unsigned int cpu = policy->cpu; | 193 | unsigned int cpu = policy->cpu; |
194 | if (cpufreq_stats_table[cpu]) | 194 | if (cpufreq_stats_table[cpu]) |
195 | return -EBUSY; | 195 | return -EBUSY; |
196 | if ((stat = kmalloc(sizeof(struct cpufreq_stats), GFP_KERNEL)) == NULL) | 196 | if ((stat = kzalloc(sizeof(struct cpufreq_stats), GFP_KERNEL)) == NULL) |
197 | return -ENOMEM; | 197 | return -ENOMEM; |
198 | memset(stat, 0, sizeof (struct cpufreq_stats)); | ||
199 | 198 | ||
200 | data = cpufreq_cpu_get(cpu); | 199 | data = cpufreq_cpu_get(cpu); |
200 | if (data == NULL) { | ||
201 | ret = -EINVAL; | ||
202 | goto error_get_fail; | ||
203 | } | ||
204 | |||
201 | if ((ret = sysfs_create_group(&data->kobj, &stats_attr_group))) | 205 | if ((ret = sysfs_create_group(&data->kobj, &stats_attr_group))) |
202 | goto error_out; | 206 | goto error_out; |
203 | 207 | ||
@@ -217,12 +221,11 @@ cpufreq_stats_create_table (struct cpufreq_policy *policy, | |||
217 | alloc_size += count * count * sizeof(int); | 221 | alloc_size += count * count * sizeof(int); |
218 | #endif | 222 | #endif |
219 | stat->max_state = count; | 223 | stat->max_state = count; |
220 | stat->time_in_state = kmalloc(alloc_size, GFP_KERNEL); | 224 | stat->time_in_state = kzalloc(alloc_size, GFP_KERNEL); |
221 | if (!stat->time_in_state) { | 225 | if (!stat->time_in_state) { |
222 | ret = -ENOMEM; | 226 | ret = -ENOMEM; |
223 | goto error_out; | 227 | goto error_out; |
224 | } | 228 | } |
225 | memset(stat->time_in_state, 0, alloc_size); | ||
226 | stat->freq_table = (unsigned int *)(stat->time_in_state + count); | 229 | stat->freq_table = (unsigned int *)(stat->time_in_state + count); |
227 | 230 | ||
228 | #ifdef CONFIG_CPU_FREQ_STAT_DETAILS | 231 | #ifdef CONFIG_CPU_FREQ_STAT_DETAILS |
@@ -245,6 +248,7 @@ cpufreq_stats_create_table (struct cpufreq_policy *policy, | |||
245 | return 0; | 248 | return 0; |
246 | error_out: | 249 | error_out: |
247 | cpufreq_cpu_put(data); | 250 | cpufreq_cpu_put(data); |
251 | error_get_fail: | ||
248 | kfree(stat); | 252 | kfree(stat); |
249 | cpufreq_stats_table[cpu] = NULL; | 253 | cpufreq_stats_table[cpu] = NULL; |
250 | return ret; | 254 | return ret; |