diff options
author | viresh kumar <viresh.kumar@linaro.org> | 2013-03-22 06:13:52 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-03-25 10:13:16 -0400 |
commit | 187da1d97f3a949b967274d7ee2f95d3a4f39251 (patch) | |
tree | 996416fe804a88984be9ed337a151127a472eb7e | |
parent | 05e99c8cf9d4e53ef6e016815db40a89a6156529 (diff) |
cpufreq: stats: do cpufreq_cpu_put() corresponding to cpufreq_cpu_get()
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>
-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 2fd779eb1ed1..bfd6273fd873 100644 --- a/drivers/cpufreq/cpufreq_stats.c +++ b/drivers/cpufreq/cpufreq_stats.c | |||
@@ -180,15 +180,19 @@ static void cpufreq_stats_free_sysfs(unsigned int cpu) | |||
180 | { | 180 | { |
181 | struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); | 181 | struct cpufreq_policy *policy = cpufreq_cpu_get(cpu); |
182 | 182 | ||
183 | if (!cpufreq_frequency_get_table(cpu)) | 183 | if (!policy) |
184 | return; | 184 | return; |
185 | 185 | ||
186 | if (policy && !policy_is_shared(policy)) { | 186 | if (!cpufreq_frequency_get_table(cpu)) |
187 | goto put_ref; | ||
188 | |||
189 | if (!policy_is_shared(policy)) { | ||
187 | pr_debug("%s: Free sysfs stat\n", __func__); | 190 | pr_debug("%s: Free sysfs stat\n", __func__); |
188 | sysfs_remove_group(&policy->kobj, &stats_attr_group); | 191 | sysfs_remove_group(&policy->kobj, &stats_attr_group); |
189 | } | 192 | } |
190 | if (policy) | 193 | |
191 | cpufreq_cpu_put(policy); | 194 | put_ref: |
195 | cpufreq_cpu_put(policy); | ||
192 | } | 196 | } |
193 | 197 | ||
194 | static int cpufreq_stats_create_table(struct cpufreq_policy *policy, | 198 | static int cpufreq_stats_create_table(struct cpufreq_policy *policy, |