Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755732Ab2KVSq7 (ORCPT ); Thu, 22 Nov 2012 13:46:59 -0500 Received: from mailout3.samsung.com ([203.254.224.33]:8903 "EHLO mailout3.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755700Ab2KVSqz (ORCPT ); Thu, 22 Nov 2012 13:46:55 -0500 X-AuditID: cbfee61b-b7f616d00000319b-ec-50adc7f18911 From: MyungJoo Ham To: serge@hallyn.com Cc: myungjoo.ham@gmail.com, linux-pm@vger.kernel.org, rjw@sisk.pl, keescook@chromium.org, serge.hallyn@canonical.com, linux-kernel@vger.kernel.org Subject: [PATCH] PM / devfreq: missing rcu_read_lock() added for find_device_opp() Date: Thu, 22 Nov 2012 15:36:32 +0900 Message-id: <1353566192-7079-1-git-send-email-myungjoo.ham@samsung.com> X-Mailer: git-send-email 1.7.5.4 In-reply-to: <20121121134621.GA30575@mail.hallyn.com> References: <20121121134621.GA30575@mail.hallyn.com> DLP-Filter: Pass X-MTR: 20000000000000000@CPGS X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFnrILMWRmVeSWpSXmKPExsVy+t8zXd2Px9cGGEy5KWZxedccNovPvUcY HZg8Pm+SC2CM4rJJSc3JLEst0rdL4MronDOLtWA1X8XsJwfYGhhbeboYOTkkBEwk5rycyQZh i0lcuLceyObiEBJYxijxe+t1ZpiiHXNus0IkFjFKzJ76mBHCaWGS6G7exgpSxSagK7F1w10W EFtEQESi9cgSZpAiZoEpjBLz1y0CGyUsECJx9NMFoG4ODhYBVYkX38pBwrwC7hKbvz5lh9im IPHryCqwmZwCphIfGueAtQoBXXH+wlkmEJtFQEDi2+RDLCBjJARkJTYdAFslIXCbTeLFGpir JSUOrrjBMoFReAEjwypG0dSC5ILipPRcI73ixNzi0rx0veT83E2MkHCU3sG4qsHiEKMAB6MS D2+GwdoAIdbEsuLK3EOMEhzMSiK8iwqAQrwpiZVVqUX58UWlOanFhxh9g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u5qDgR AA8LBUCjAgAA X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2019 Lines: 66 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(). 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 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/