From patchwork Fri Mar 22 10:13:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Viresh Kumar X-Patchwork-Id: 2318891 Return-Path: X-Original-To: patchwork-linux-pm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id AC2F4400E6 for ; Fri, 22 Mar 2013 10:14:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933230Ab3CVKOG (ORCPT ); Fri, 22 Mar 2013 06:14:06 -0400 Received: from mail-pb0-f50.google.com ([209.85.160.50]:48614 "EHLO mail-pb0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933066Ab3CVKOF (ORCPT ); Fri, 22 Mar 2013 06:14:05 -0400 Received: by mail-pb0-f50.google.com with SMTP id up1so2927553pbc.23 for ; Fri, 22 Mar 2013 03:14:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=LkDbPtHQkoEm/TTWBZJdtSyr8/ythO6exvZExBeT3og=; b=pQiL3Vu22/vIF8gQLS7cBHOxgZ/AWqfN6R+6iPivqDgHF3laGfw43cF8mraAZ0gogm ViGEy67Sr45y7TVLvgcC9fhfXUTGc7h5bX8EwDOO8Ypw+cTnXD6Gc9/w37WnEG3F6zZ3 OUvncjkkhMV7ao4ffkheu4Y98FS3pOCtLS6/5WI80Rsjh8JVFd/tl7C6sZHwx2b3PLol I6ZiEvlpW5E47pFcZMofITgX0lP0GSeF0mLFEsUer4n5EgGhY0ZiW7QbeSgoFfQR6EER 6UgIX6HU2x4JWabYMXzXTqn+LZGEByTim0mIXFmqGkmtnHuh3bz38Epr9qJVlxgMtixV qaKA== X-Received: by 10.68.180.162 with SMTP id dp2mr1612361pbc.214.1363947244419; Fri, 22 Mar 2013 03:14:04 -0700 (PDT) Received: from localhost ([122.167.88.231]) by mx.google.com with ESMTPS id xc4sm1851986pbc.41.2013.03.22.03.13.59 (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 22 Mar 2013 03:14:03 -0700 (PDT) From: Viresh Kumar To: rjw@sisk.pl Cc: arvind.chauhan@arm.com, robin.randhawa@arm.com, Steve.Bannister@arm.com, Liviu.Dudau@arm.com, charles.garcia-tobin@arm.com, cpufreq@vger.kernel.org, linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, linaro-kernel@lists.linaro.org, Viresh Kumar Subject: [PATCH] cpufreq: stats: do cpufreq_cpu_put() corresponding to cpufreq_cpu_get Date: Fri, 22 Mar 2013 15:43:52 +0530 Message-Id: <234906745c34fb72b0c450d897f261a22ed18d40.1363947023.git.viresh.kumar@linaro.org> X-Mailer: git-send-email 1.7.12.rc2.18.g61b472e X-Gm-Message-State: ALoCoQl8bQupXB3JPVYQEi94DXmJCmprcoABF0A4I3IiLTSNtM46iDu00NcwByqWo63FmkNNJAiv Sender: linux-pm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pm@vger.kernel.org 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 Acked-by: Amit Kucheria Signed-off-by: Viresh Kumar --- 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,