public inbox for linux-omap@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] power: opp: Fix rcu_dereference_check() without protection!
@ 2011-06-14 13:03 Santosh Shilimkar
  2011-06-14 15:38 ` Menon, Nishanth
  0 siblings, 1 reply; 3+ messages in thread
From: Santosh Shilimkar @ 2011-06-14 13:03 UTC (permalink / raw)
  To: linux-pm
  Cc: linux-kernel, linux-omap, Santosh Shilimkar, Rafael J. Wysocki,
	Nishanth Menon, Kevin Hilman

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 <santosh.shilimkar@ti.com>
Cc: Rafael J. Wysocki <rjw@sisk.pl>
Cc: Nishanth Menon <nm@ti.com>
Cc: Kevin Hilman <khilman@deeprootsystems.com>
---
 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
-- 
1.6.0.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] power: opp: Fix rcu_dereference_check() without protection!
  2011-06-14 13:03 [PATCH] power: opp: Fix rcu_dereference_check() without protection! Santosh Shilimkar
@ 2011-06-14 15:38 ` Menon, Nishanth
  2011-06-15  6:20   ` Santosh Shilimkar
  0 siblings, 1 reply; 3+ messages in thread
From: Menon, Nishanth @ 2011-06-14 15:38 UTC (permalink / raw)
  To: Santosh Shilimkar; +Cc: Kevin Hilman, linux-pm, linux-omap, linux-kernel

On Tue, Jun 14, 2011 at 08:03, Santosh Shilimkar
<santosh.shilimkar@ti.com> 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 <santosh.shilimkar@ti.com>
> Cc: Rafael J. Wysocki <rjw@sisk.pl>
> Cc: Nishanth Menon <nm@ti.com>
> Cc: Kevin Hilman <khilman@deeprootsystems.com>
> ---
>  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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] power: opp: Fix rcu_dereference_check() without protection!
  2011-06-14 15:38 ` Menon, Nishanth
@ 2011-06-15  6:20   ` Santosh Shilimkar
  0 siblings, 0 replies; 3+ messages in thread
From: Santosh Shilimkar @ 2011-06-15  6:20 UTC (permalink / raw)
  To: Menon, Nishanth
  Cc: linux-pm, linux-kernel, linux-omap, Rafael J. Wysocki,
	Kevin Hilman

On 6/14/2011 9:08 PM, Menon, Nishanth wrote:
> On Tue, Jun 14, 2011 at 08:03, Santosh Shilimkar
> <santosh.shilimkar@ti.com>  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<santosh.shilimkar@ti.com>
>> Cc: Rafael J. Wysocki<rjw@sisk.pl>
>> Cc: Nishanth Menon<nm@ti.com>
>> Cc: Kevin Hilman<khilman@deeprootsystems.com>
>> ---
>>   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.
>
Fair enough. if the whole fn is under the lock then it's not
necessary.

Regards
Santosh

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-06-15  6:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-06-14 13:03 [PATCH] power: opp: Fix rcu_dereference_check() without protection! Santosh Shilimkar
2011-06-14 15:38 ` Menon, Nishanth
2011-06-15  6:20   ` Santosh Shilimkar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox