From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757794AbcFAKeu (ORCPT ); Wed, 1 Jun 2016 06:34:50 -0400 Received: from mail-pf0-f181.google.com ([209.85.192.181]:36628 "EHLO mail-pf0-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757333AbcFAKel (ORCPT ); Wed, 1 Jun 2016 06:34:41 -0400 From: Viresh Kumar To: Rafael Wysocki , Viresh Kumar , Benjamin Herrenschmidt , Paul Mackerras , Michael Ellerman Cc: linaro-kernel@lists.linaro.org, linux-pm@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/8] cpufreq: powerenv: Fix memory leak Date: Wed, 1 Jun 2016 16:04:17 +0530 Message-Id: X-Mailer: git-send-email 2.7.1.410.g6faf27b In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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