From patchwork Wed Jun 1 10:34:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 69014 Delivered-To: patch@linaro.org Received: by 10.140.92.199 with SMTP id b65csp15304qge; Wed, 1 Jun 2016 03:36:02 -0700 (PDT) X-Received: by 10.98.106.65 with SMTP id f62mr7251486pfc.126.1464777362657; Wed, 01 Jun 2016 03:36:02 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q86si50411766pfd.90.2016.06.01.03.36.02; Wed, 01 Jun 2016 03:36:02 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757799AbcFAKeu (ORCPT + 30 others); 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 Received: by mail-pf0-f181.google.com with SMTP id f144so12900840pfa.3 for ; Wed, 01 Jun 2016 03:34:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :in-reply-to:references; bh=0kOakHGVSRKg5nxWkfD6TbophAX3I3xthkkE8oeRoi0=; b=eAgMCgwcxMyfovuo2YSd5AeczyToy3aVD/ICQaBib4WsprPK2XBbwvnJcdU3U1LBDO AIV+DnSI9B1rK1J62sfbO5CoDpPSt8MoqxGVtCKwYbgNa+Qq1LuMNnLLOvhmkOcwDgmO /QgljDQR3e2l3WGNBShoBVn/g9AvjMxdE/Cu4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:in-reply-to:references; bh=0kOakHGVSRKg5nxWkfD6TbophAX3I3xthkkE8oeRoi0=; b=JYm+echU/sCW7+E2u2sm2R47KIe8vrOovTwhICB7gXsOsBuBqzL0+Ne4vj8pEH29PO 70iJXTQ8CxAsueS2f7F0409F9EVNTnt4BS7iNnMMH9Aaczdpu/jYKbNkoksanOFne0AU PkWJQkVoPDfu4scYgzx1Imq6V+rJVwmofaU/XE2U75j4bmgNVLQzcl3lMmQK/6W0vQGK MIEJsFuWrabMDINfCZfUR6SpNklNo5Tc0HZvpY0SzfrsiceNjACblldzPZqOorZMDCyD lD7tzHd+AX6FDDgAhu0d+b6mz79HU9iT6ikXFlflkfNcn7mlGguLvQP2YMfAESD4gB4A PGTw== X-Gm-Message-State: ALyK8tJxg5arFUD8MYI+yehJUzqPHk0lU9mGk8yAZmcjOaUt2QhxiapEs3ogLRkyj8q8p9Y2 X-Received: by 10.98.102.205 with SMTP id s74mr7170878pfj.54.1464777280939; Wed, 01 Jun 2016 03:34:40 -0700 (PDT) Received: from localhost ([122.167.174.248]) by smtp.gmail.com with ESMTPSA id v1sm23336363pfa.93.2016.06.01.03.34.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Jun 2016 03:34:40 -0700 (PDT) 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 Precedence: bulk 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(-) -- 2.7.1.410.g6faf27b 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();