From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753425Ab1FNPoN (ORCPT ); Tue, 14 Jun 2011 11:44:13 -0400 Received: from na3sys009aog109.obsmtp.com ([74.125.149.201]:36757 "EHLO na3sys009aog109.obsmtp.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751671Ab1FNPoK convert rfc822-to-8bit (ORCPT ); Tue, 14 Jun 2011 11:44:10 -0400 MIME-Version: 1.0 In-Reply-To: <1308056600-17601-1-git-send-email-santosh.shilimkar@ti.com> References: <1308056600-17601-1-git-send-email-santosh.shilimkar@ti.com> From: "Menon, Nishanth" Date: Tue, 14 Jun 2011 10:38:37 -0500 Message-ID: Subject: Re: [PATCH] power: opp: Fix rcu_dereference_check() without protection! To: Santosh Shilimkar Cc: linux-pm@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-omap@vger.kernel.org, "Rafael J. Wysocki" , Kevin Hilman Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Jun 14, 2011 at 08:03, Santosh Shilimkar wrote: > With RCU debug options enabled, below warning is observed. > > =================================================== > [ INFO: suspicious rcu_dereference_check() usage. ] > --------------------------------------------------- > drivers/base/power/opp.c:151 invoked rcu_dereference_check() without protection! > > other info that might help us debug this: > > rcu_scheduler_active = 1, debug_locks = 1 > no locks held by swapper/1. > ... > > --------------------------------------------------- > > Fix the same by protecting it with rcu_read lock. > > Signed-off-by: Santosh Shilimkar > Cc: Rafael J. Wysocki > Cc: Nishanth Menon > Cc: Kevin Hilman > --- >  drivers/base/power/opp.c |    2 ++ >  1 files changed, 2 insertions(+), 0 deletions(-) > > diff --git a/drivers/base/power/opp.c b/drivers/base/power/opp.c > index 56a6899..cbed5e1 100644 > --- a/drivers/base/power/opp.c > +++ b/drivers/base/power/opp.c > @@ -148,7 +148,9 @@ unsigned long opp_get_voltage(struct opp *opp) >        struct opp *tmp_opp; >        unsigned long v = 0; > > +       rcu_read_lock(); >        tmp_opp = rcu_dereference(opp); > +       rcu_read_unlock(); >        if (unlikely(IS_ERR_OR_NULL(tmp_opp)) || !tmp_opp->available) >                pr_err("%s: Invalid parameters\n", __func__); >        else NAK. please read the Documentation/power/opp.txt the usage is as follows: rcu_read_lock(); opp = opp_find_freq_ceil(); voltage = opp_get_voltage(opp); rcu_read_unlock(); the reason for this is that the opp pointer is not safe if we lock just the dereferencing. Regards, Nishanth Menon