Linux Power Management development
 help / color / mirror / Atom feed
* [PATCH] cpufreq: stats: do cpufreq_cpu_put() corresponding to cpufreq_cpu_get
@ 2013-03-22 10:13 Viresh Kumar
  2013-03-22 11:12 ` Amit Kucheria
  0 siblings, 1 reply; 10+ messages in thread
From: Viresh Kumar @ 2013-03-22 10:13 UTC (permalink / raw)
  To: rjw
  Cc: arvind.chauhan, robin.randhawa, Steve.Bannister, Liviu.Dudau,
	charles.garcia-tobin, cpufreq, linux-pm, linux-kernel,
	linaro-kernel, Viresh Kumar

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.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/cpufreq_stats.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/cpufreq/cpufreq_stats.c b/drivers/cpufreq/cpufreq_stats.c
index 2fd779e..bfd6273 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)
 {
 	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,
-- 
1.7.12.rc2.18.g61b472e


^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2013-03-22 13:15 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-22 10:13 [PATCH] cpufreq: stats: do cpufreq_cpu_put() corresponding to cpufreq_cpu_get Viresh Kumar
2013-03-22 11:12 ` Amit Kucheria
2013-03-22 11:17   ` Viresh Kumar
2013-03-22 11:47     ` Rafael J. Wysocki
2013-03-22 11:59   ` Rafael J. Wysocki
2013-03-22 11:55     ` Viresh Kumar
2013-03-22 11:59       ` Amit Kucheria
2013-03-22 12:12       ` Rafael J. Wysocki
2013-03-22 12:10         ` Viresh Kumar
2013-03-22 13:22           ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox