Commit 41dc750e authored by Li, Fei's avatar Li, Fei Committed by Rafael J. Wysocki

cpuidle: check dev before usage in cpuidle_use_deepest_state()

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: bb8313b6 (cpuidle: Allow enforcing deepest idle state selection)
Signed-off-by: default avatarLi, Fei <fei.li@intel.com>
Tested-by: default avatarShi, Feng <fengx.shi@intel.com>
Reviewed-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: 4.10+ <stable@vger.kernel.org> # 4.10+
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 0baa91cb
...@@ -111,6 +111,7 @@ void cpuidle_use_deepest_state(bool enable) ...@@ -111,6 +111,7 @@ void cpuidle_use_deepest_state(bool enable)
preempt_disable(); preempt_disable();
dev = cpuidle_get_device(); dev = cpuidle_get_device();
if (dev)
dev->use_deepest_state = enable; dev->use_deepest_state = enable;
preempt_enable(); preempt_enable();
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment