Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1411078

[PATCH 3/8] cpufreq: powerenv: Fix memory leak

From Viresh Kumar <viresh.kumar@linaro.org>
Newsgroups linux.kernel
Subject [PATCH 3/8] cpufreq: powerenv: Fix memory leak
Date 2016-06-01 12:40 +0200
Message-ID <rFbJ7-7eG-21@gated-at.bofh.it> (permalink)
References <rFbJ7-7eG-3@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


The policy is copied (unnecessarily) and is never freed. Fix it by just
getting a reference to the existing policy structure and putting it
back.

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
---
 drivers/cpufreq/powernv-cpufreq.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/drivers/cpufreq/powernv-cpufreq.c b/drivers/cpufreq/powernv-cpufreq.c
index 54c45368e3f1..96bb4acd366e 100644
--- a/drivers/cpufreq/powernv-cpufreq.c
+++ b/drivers/cpufreq/powernv-cpufreq.c
@@ -756,15 +756,18 @@ void powernv_cpufreq_work_fn(struct work_struct *work)
 
 	chip->restore = false;
 	for_each_cpu(cpu, &mask) {
+		struct cpufreq_policy *policy = cpufreq_cpu_get(cpu)
 		int index;
-		struct cpufreq_policy policy;
 
-		cpufreq_get_policy(&policy, cpu);
-		cpufreq_frequency_table_target(&policy, policy.freq_table,
-					       policy.cur,
+		if (!policy)
+			continue;
+
+		cpufreq_frequency_table_target(policy, policy->freq_table,
+					       policy->cur,
 					       CPUFREQ_RELATION_C, &index);
-		powernv_cpufreq_target_index(&policy, index);
-		cpumask_andnot(&mask, &mask, policy.cpus);
+		powernv_cpufreq_target_index(policy, index);
+		cpumask_andnot(&mask, &mask, policy->cpus);
+		cpufreq_cpu_put(policy);
 	}
 out:
 	put_online_cpus();
-- 
2.7.1.410.g6faf27b

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH 3/8] cpufreq: powerenv: Fix memory leak Viresh Kumar <viresh.kumar@linaro.org> - 2016-06-01 12:40 +0200
  Re: [PATCH 3/8] cpufreq: powerenv: Fix memory leak Michael Ellerman <mpe@ellerman.id.au> - 2016-06-02 13:10 +0200
    Re: [PATCH 3/8] cpufreq: powerenv: Fix memory leak Viresh Kumar <viresh.kumar@linaro.org> - 2016-06-02 13:30 +0200
      Re: [PATCH 3/8] cpufreq: powerenv: Fix memory leak Michael Ellerman <mpe@ellerman.id.au> - 2016-06-02 13:40 +0200
        Re: [PATCH 3/8] cpufreq: powerenv: Fix memory leak Viresh Kumar <viresh.kumar@linaro.org> - 2016-06-02 13:50 +0200
          Re: [PATCH 3/8] cpufreq: powerenv: Fix memory leak Michael Ellerman <mpe@ellerman.id.au> - 2016-06-02 14:10 +0200

csiph-web