* [PATCH V3] cpuidle: check dev before usage in cpuidle_use_deepest_state
@ 2017-05-04 9:00 Li, Fei
2017-05-04 10:16 ` Daniel Lezcano
2017-05-05 21:33 ` Rafael J. Wysocki
0 siblings, 2 replies; 6+ messages in thread
From: Li, Fei @ 2017-05-04 9:00 UTC (permalink / raw)
To: Andy Shevchenko, Shi, FengX, rjw, daniel.lezcano
Cc: linux-pm, linux-kernel, Koul, Vinod
In case of there is no cpuidle devices registered, dev will be null, and
panic will be triggered like below;
In this patch, add checking of dev before usage, like that done in
cpuidle_idle_call.
Panic without fix:
[ 184.961328] BUG: unable to handle kernel NULL pointer dereference at
(null)
[ 184.961328] IP: cpuidle_use_deepest_state+0x30/0x60
...
[ 184.961328] play_idle+0x8d/0x210
[ 184.961328] ? __schedule+0x359/0x8e0
[ 184.961328] ? _raw_spin_unlock_irqrestore+0x28/0x50
[ 184.961328] ? kthread_queue_delayed_work+0x41/0x80
[ 184.961328] clamp_idle_injection_func+0x64/0x1e0
Fixes: bb8313b603eb8 ("cpuidle: Allow enforcing deepest idle state selection")
Signed-off-by: Li, Fei <fei.li@intel.com>
Tested-by: Shi, Feng <fengx.shi@intel.com>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Reviewed-by: Koul, Vinod <vinod.koul@intel.com>
---
drivers/cpuidle/cpuidle.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index 548b90b..2706be7 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -111,7 +111,8 @@ void cpuidle_use_deepest_state(bool enable)
preempt_disable();
dev = cpuidle_get_device();
- dev->use_deepest_state = enable;
+ if (dev)
+ dev->use_deepest_state = enable;
preempt_enable();
}
--
1.9.1
Best Regards,
Fei
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH V3] cpuidle: check dev before usage in cpuidle_use_deepest_state
2017-05-04 9:00 [PATCH V3] cpuidle: check dev before usage in cpuidle_use_deepest_state Li, Fei
@ 2017-05-04 10:16 ` Daniel Lezcano
2017-05-05 1:53 ` Li, Fei
2017-05-05 21:33 ` Rafael J. Wysocki
1 sibling, 1 reply; 6+ messages in thread
From: Daniel Lezcano @ 2017-05-04 10:16 UTC (permalink / raw)
To: Li, Fei
Cc: Andy Shevchenko, Shi, FengX, rjw, linux-pm, linux-kernel, Koul, Vinod
On Thu, May 04, 2017 at 09:00:52AM +0000, Li, Fei wrote:
> In case of there is no cpuidle devices registered, dev will be null, and
> panic will be triggered like below;
> In this patch, add checking of dev before usage, like that done in
> cpuidle_idle_call.
>
> Panic without fix:
> [ 184.961328] BUG: unable to handle kernel NULL pointer dereference at
> (null)
> [ 184.961328] IP: cpuidle_use_deepest_state+0x30/0x60
> ...
> [ 184.961328] play_idle+0x8d/0x210
> [ 184.961328] ? __schedule+0x359/0x8e0
> [ 184.961328] ? _raw_spin_unlock_irqrestore+0x28/0x50
> [ 184.961328] ? kthread_queue_delayed_work+0x41/0x80
> [ 184.961328] clamp_idle_injection_func+0x64/0x1e0
>
> Fixes: bb8313b603eb8 ("cpuidle: Allow enforcing deepest idle state selection")
> Signed-off-by: Li, Fei <fei.li@intel.com>
> Tested-by: Shi, Feng <fengx.shi@intel.com>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Reviewed-by: Koul, Vinod <vinod.koul@intel.com>
> ---
> drivers/cpuidle/cpuidle.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
> index 548b90b..2706be7 100644
> --- a/drivers/cpuidle/cpuidle.c
> +++ b/drivers/cpuidle/cpuidle.c
> @@ -111,7 +111,8 @@ void cpuidle_use_deepest_state(bool enable)
>
> preempt_disable();
> dev = cpuidle_get_device();
> - dev->use_deepest_state = enable;
> + if (dev)
> + dev->use_deepest_state = enable;
This change is acceptable as a hot fix but the question is 'why is this
function called if there is no cpuidle driver registered?'
> preempt_enable();
> }
>
> --
> 1.9.1
>
> Best Regards,
> Fei
--
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
<http://twitter.com/#!/linaroorg> Twitter |
<http://www.linaro.org/linaro-blog/> Blog
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH V3] cpuidle: check dev before usage in cpuidle_use_deepest_state
2017-05-04 10:16 ` Daniel Lezcano
@ 2017-05-05 1:53 ` Li, Fei
0 siblings, 0 replies; 6+ messages in thread
From: Li, Fei @ 2017-05-05 1:53 UTC (permalink / raw)
To: Daniel Lezcano
Cc: Andy Shevchenko, Shi, FengX, rjw, linux-pm, linux-kernel, Koul, Vinod
On Thursday, May 4, 2017 6:16 PM Daniel Lezcano wrote:
> >
> > preempt_disable();
> > dev = cpuidle_get_device();
> > - dev->use_deepest_state = enable;
> > + if (dev)
> > + dev->use_deepest_state = enable;
>
>
> This change is acceptable as a hot fix but the question is 'why is this
> function called if there is no cpuidle driver registered?'
It's called as below:
clamp_idle_injection_func
-> play_idle
-> cpuidle_use_deepest_state
In play_idle, if no cpuidle driver registered, cpu_idle_poll can be called.
It seems to go too far if not calling play_idle in case of no cpuidle driver
registered.
At present no other suitable and simple fix seen.
>
> > preempt_enable();
> > }
> >
> > --
> > 1.9.1
> >
> > Best Regards,
> > Fei
>
> --
>
> <http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs
>
> Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook |
> <http://twitter.com/#!/linaroorg> Twitter |
> <http://www.linaro.org/linaro-blog/> Blog
Best Regards,
Fei
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH V3] cpuidle: check dev before usage in cpuidle_use_deepest_state
2017-05-04 9:00 [PATCH V3] cpuidle: check dev before usage in cpuidle_use_deepest_state Li, Fei
2017-05-04 10:16 ` Daniel Lezcano
@ 2017-05-05 21:33 ` Rafael J. Wysocki
2017-05-05 22:21 ` Andy Shevchenko
1 sibling, 1 reply; 6+ messages in thread
From: Rafael J. Wysocki @ 2017-05-05 21:33 UTC (permalink / raw)
To: Li, Fei
Cc: Andy Shevchenko, Shi, FengX, daniel.lezcano, linux-pm,
linux-kernel, Koul, Vinod
On Thursday, May 04, 2017 09:00:52 AM Li, Fei wrote:
> In case of there is no cpuidle devices registered, dev will be null, and
> panic will be triggered like below;
> In this patch, add checking of dev before usage, like that done in
> cpuidle_idle_call.
>
> Panic without fix:
> [ 184.961328] BUG: unable to handle kernel NULL pointer dereference at
> (null)
> [ 184.961328] IP: cpuidle_use_deepest_state+0x30/0x60
> ...
> [ 184.961328] play_idle+0x8d/0x210
> [ 184.961328] ? __schedule+0x359/0x8e0
> [ 184.961328] ? _raw_spin_unlock_irqrestore+0x28/0x50
> [ 184.961328] ? kthread_queue_delayed_work+0x41/0x80
> [ 184.961328] clamp_idle_injection_func+0x64/0x1e0
>
> Fixes: bb8313b603eb8 ("cpuidle: Allow enforcing deepest idle state selection")
> Signed-off-by: Li, Fei <fei.li@intel.com>
> Tested-by: Shi, Feng <fengx.shi@intel.com>
> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Reviewed-by: Koul, Vinod <vinod.koul@intel.com>
> ---
> drivers/cpuidle/cpuidle.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
> index 548b90b..2706be7 100644
> --- a/drivers/cpuidle/cpuidle.c
> +++ b/drivers/cpuidle/cpuidle.c
> @@ -111,7 +111,8 @@ void cpuidle_use_deepest_state(bool enable)
>
> preempt_disable();
> dev = cpuidle_get_device();
> - dev->use_deepest_state = enable;
> + if (dev)
> + dev->use_deepest_state = enable;
> preempt_enable();
> }
>
> --
> 1.9.1
A previous version of this has been applied and I don't see any differences
in the code changes.
Thanks,
Rafael
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH V3] cpuidle: check dev before usage in cpuidle_use_deepest_state
2017-05-05 21:33 ` Rafael J. Wysocki
@ 2017-05-05 22:21 ` Andy Shevchenko
2017-05-08 0:52 ` Li, Fei
0 siblings, 1 reply; 6+ messages in thread
From: Andy Shevchenko @ 2017-05-05 22:21 UTC (permalink / raw)
To: Rafael J. Wysocki
Cc: Li, Fei, Andy Shevchenko, Shi, FengX, daniel.lezcano, linux-pm,
linux-kernel, Koul, Vinod
On Sat, May 6, 2017 at 12:33 AM, Rafael J. Wysocki <rjw@rjwysocki.net> wrote:
> On Thursday, May 04, 2017 09:00:52 AM Li, Fei wrote:
>> Fixes: bb8313b603eb8 ("cpuidle: Allow enforcing deepest idle state selection")
>> Signed-off-by: Li, Fei <fei.li@intel.com>
>> Tested-by: Shi, Feng <fengx.shi@intel.com>
>> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
>> Reviewed-by: Koul, Vinod <vinod.koul@intel.com>
> A previous version of this has been applied and I don't see any differences
> in the code changes.
AFAIR only tags (above) had been extended in v3.
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH V3] cpuidle: check dev before usage in cpuidle_use_deepest_state
2017-05-05 22:21 ` Andy Shevchenko
@ 2017-05-08 0:52 ` Li, Fei
0 siblings, 0 replies; 6+ messages in thread
From: Li, Fei @ 2017-05-08 0:52 UTC (permalink / raw)
To: Andy Shevchenko, Rafael J. Wysocki
Cc: Andy Shevchenko, Shi, FengX, daniel.lezcano, linux-pm,
linux-kernel, Koul, Vinod
> >> Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> >> Reviewed-by: Koul, Vinod <vinod.koul@intel.com>
>
> > A previous version of this has been applied and I don't see any differences
> > in the code changes.
>
> AFAIR only tags (above) had been extended in v3.
Thanks.
Yes, for v3 no change in code, and only tags "Reviewed-by" added.
>
> --
> With Best Regards,
> Andy Shevchenko
Best Regards,
Fei
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2017-05-08 0:52 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-04 9:00 [PATCH V3] cpuidle: check dev before usage in cpuidle_use_deepest_state Li, Fei
2017-05-04 10:16 ` Daniel Lezcano
2017-05-05 1:53 ` Li, Fei
2017-05-05 21:33 ` Rafael J. Wysocki
2017-05-05 22:21 ` Andy Shevchenko
2017-05-08 0:52 ` Li, Fei
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.