]> git.karo-electronics.de Git - linux-beck.git/commitdiff
cpufreq: stats: Fix error handling in __cpufreq_stats_create_table()
authorSaravana Kannan <skannan@codeaurora.org>
Fri, 28 Feb 2014 01:58:35 +0000 (17:58 -0800)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Sat, 1 Mar 2014 23:55:50 +0000 (00:55 +0100)
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>
drivers/cpufreq/cpufreq_stats.c

index e4bd27f1a9d8cfc01de1d9416fdda8be0e10493f..c52b44071100ab7689c9d43c40ce0be2af47ec98 100644 (file)
@@ -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);
 
@@ -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;