Skip to content

Commit

Permalink
cpufreq: stats: do cpufreq_cpu_put() corresponding to cpufreq_cpu_get()
Browse files Browse the repository at this point in the history
In cpufreq_stats_free_sysfs() we aren't balancing calls to
cpufreq_cpu_get() with cpufreq_cpu_put(). This will never let us have
ref count to policy->kobj as zero.

We will get a hang if somehow cpufreq_driver_unregister() is called.
And that can happen when we compile our driver as module and
insmod/rmmod it.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Acked-by: Amit Kucheria <amit.kucheria@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
viresh kumar authored and Rafael J. Wysocki committed Mar 25, 2013
1 parent 05e99c8 commit 187da1d
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions drivers/cpufreq/cpufreq_stats.c
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,19 @@ static void cpufreq_stats_free_sysfs(unsigned int cpu)
{
struct cpufreq_policy *policy = cpufreq_cpu_get(cpu);

if (!cpufreq_frequency_get_table(cpu))
if (!policy)
return;

if (policy && !policy_is_shared(policy)) {
if (!cpufreq_frequency_get_table(cpu))
goto put_ref;

if (!policy_is_shared(policy)) {
pr_debug("%s: Free sysfs stat\n", __func__);
sysfs_remove_group(&policy->kobj, &stats_attr_group);
}
if (policy)
cpufreq_cpu_put(policy);

put_ref:
cpufreq_cpu_put(policy);
}

static int cpufreq_stats_create_table(struct cpufreq_policy *policy,
Expand Down

0 comments on commit 187da1d

Please sign in to comment.