Skip to content

Commit

Permalink
cpufreq: stats: Fix error handling in __cpufreq_stats_create_table()
Browse files Browse the repository at this point in the history
Remove sysfs group if __cpufreq_stats_create_table() fails after creating
one.

Acked-by: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: Saravana Kannan <skannan@codeaurora.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Saravana Kannan authored and Rafael J. Wysocki committed Mar 1, 2014
1 parent b24a5b6 commit 0b7528d
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/cpufreq/cpufreq_stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ static int __cpufreq_stats_create_table(struct cpufreq_policy *policy,
stat->time_in_state = kzalloc(alloc_size, GFP_KERNEL);
if (!stat->time_in_state) {
ret = -ENOMEM;
goto error_out;
goto error_alloc;
}
stat->freq_table = (unsigned int *)(stat->time_in_state + count);

Expand All @@ -237,6 +237,8 @@ static int __cpufreq_stats_create_table(struct cpufreq_policy *policy,
stat->last_index = freq_table_get_index(stat, policy->cur);
spin_unlock(&cpufreq_stats_lock);
return 0;
error_alloc:
sysfs_remove_group(&policy->kobj, &stats_attr_group);
error_out:
kfree(stat);
per_cpu(cpufreq_stats_table, cpu) = NULL;
Expand Down

0 comments on commit 0b7528d

Please sign in to comment.