From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756657AbcANR6L (ORCPT ); Thu, 14 Jan 2016 12:58:11 -0500 Received: from foss.arm.com ([217.140.101.70]:48383 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756559AbcANR6J (ORCPT ); Thu, 14 Jan 2016 12:58:09 -0500 Date: Thu, 14 Jan 2016 17:58:32 +0000 From: Juri Lelli To: Viresh Kumar Cc: linux-kernel@vger.kernel.org, linux-pm@vger.kernel.org, peterz@infradead.org, rjw@rjwysocki.net, mturquette@baylibre.com, steve.muckle@linaro.org, vincent.guittot@linaro.org, morten.rasmussen@arm.com, dietmar.eggemann@arm.com Subject: Re: [RFC PATCH 12/19] cpufreq: fix locking of policy->rwsem in cpufreq_init_policy Message-ID: <20160114175832.GO18603@e106622-lin> References: <1452533760-13787-1-git-send-email-juri.lelli@arm.com> <1452533760-13787-13-git-send-email-juri.lelli@arm.com> <20160112103956.GD1084@ubuntu> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160112103956.GD1084@ubuntu> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/01/16 16:09, Viresh Kumar wrote: > On 11-01-16, 17:35, Juri Lelli wrote: > > There are paths in cpufreq_init_policy where policy is used, but its rwsem > > is not held. > > > > Fix it. > > > > Cc: "Rafael J. Wysocki" > > Cc: Viresh Kumar > > Signed-off-by: Juri Lelli > > --- > > drivers/cpufreq/cpufreq.c | 11 ++++++++--- > > 1 file changed, 8 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c > > index e7fc5c9..2c7cc6c73 100644 > > --- a/drivers/cpufreq/cpufreq.c > > +++ b/drivers/cpufreq/cpufreq.c > > @@ -998,21 +998,24 @@ static int cpufreq_add_policy_cpu(struct cpufreq_policy *policy, unsigned int cp > > { > > int ret = 0; > > > > + down_write(&policy->rwsem); > > + > > /* Has this CPU been taken care of already? */ > > - if (cpumask_test_cpu(cpu, policy->cpus)) > > + if (cpumask_test_cpu(cpu, policy->cpus)) { > > + up_write(&policy->rwsem); > > Perhaps create a label at the end to unlock the rwsem and jump to it? > Yep, done. Thanks, - Juri