From mboxrd@z Thu Jan 1 00:00:00 1970 From: "Serge E. Hallyn" Subject: Re: [PATCH] PM / devfreq: missing rcu_read_lock() added for find_device_opp() Date: Thu, 22 Nov 2012 14:09:28 +0000 Message-ID: <20121122140928.GA14567@mail.hallyn.com> References: <20121121134621.GA30575@mail.hallyn.com> <1353566192-7079-1-git-send-email-myungjoo.ham@samsung.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Return-path: Content-Disposition: inline In-Reply-To: <1353566192-7079-1-git-send-email-myungjoo.ham@samsung.com> Sender: linux-kernel-owner@vger.kernel.org To: MyungJoo Ham Cc: serge@hallyn.com, myungjoo.ham@gmail.com, linux-pm@vger.kernel.org, rjw@sisk.pl, keescook@chromium.org, serge.hallyn@canonical.com, linux-kernel@vger.kernel.org List-Id: linux-pm@vger.kernel.org Quoting MyungJoo Ham (myungjoo.ham@samsung.com): > opp_get_notifier() uses find_device_opp(), which requires to > held rcu_read_lock. In order to keep the notifier-header > valid, we have added rcu_read_lock(). > Reviewed-by: Serge Hallyn > Reported-by: Kees Cook > Signed-off-by: MyungJoo Ham > --- > drivers/devfreq/devfreq.c | 26 ++++++++++++++++++++------ > 1 files changed, 20 insertions(+), 6 deletions(-) > > diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c > index 1388d46..5275883 100644 > --- a/drivers/devfreq/devfreq.c > +++ b/drivers/devfreq/devfreq.c > @@ -1023,11 +1023,18 @@ struct opp *devfreq_recommended_opp(struct device *dev, unsigned long *freq, > */ > int devfreq_register_opp_notifier(struct device *dev, struct devfreq *devfreq) > { > - struct srcu_notifier_head *nh = opp_get_notifier(dev); > + struct srcu_notifier_head *nh; > + int ret = 0; > > + rcu_read_lock(); > + nh = opp_get_notifier(dev); > if (IS_ERR(nh)) > - return PTR_ERR(nh); > - return srcu_notifier_chain_register(nh, &devfreq->nb); > + ret = PTR_ERR(nh); > + rcu_read_unlock(); > + if (!ret) > + ret = srcu_notifier_chain_register(nh, &devfreq->nb); > + > + return ret; > } > > /** > @@ -1042,11 +1049,18 @@ int devfreq_register_opp_notifier(struct device *dev, struct devfreq *devfreq) > */ > int devfreq_unregister_opp_notifier(struct device *dev, struct devfreq *devfreq) > { > - struct srcu_notifier_head *nh = opp_get_notifier(dev); > + struct srcu_notifier_head *nh; > + int ret = 0; > > + rcu_read_lock(); > + nh = opp_get_notifier(dev); > if (IS_ERR(nh)) > - return PTR_ERR(nh); > - return srcu_notifier_chain_unregister(nh, &devfreq->nb); > + ret = PTR_ERR(nh); > + rcu_read_unlock(); > + if (!ret) > + ret = srcu_notifier_chain_unregister(nh, &devfreq->nb); > + > + return ret; > } > > MODULE_AUTHOR("MyungJoo Ham "); > -- > 1.7.5.4