summaryrefslogtreecommitdiff
path: root/drivers/cpuidle
diff options
context:
space:
mode:
authorToshi Kani <toshi.kani@hp.com>2012-04-01 07:37:02 +0400
committerLen Brown <len.brown@intel.com>2012-04-06 23:01:25 +0400
commitee01e663373343c63e0e3d364d09f6155378dbcc (patch)
tree22448567769278f9af4f8bff9bfc7653be94885c /drivers/cpuidle
parent54f70077768e9aba37d9c5030b43497b6d5084fb (diff)
downloadlinux-ee01e663373343c63e0e3d364d09f6155378dbcc.tar.xz
cpuidle: Fix panic in CPU off-lining with no idle driver
Fix a NULL pointer dereference panic in cpuidle_play_dead() during CPU off-lining when no cpuidle driver is registered. A cpuidle driver may be registered at boot-time based on CPU type. This patch allows an off-lined CPU to enter HLT-based idle in this condition. Signed-off-by: Toshi Kani <toshi.kani@hp.com> Cc: Boris Ostrovsky <boris.ostrovsky@amd.com> Reviewed-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com> Tested-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com> Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/cpuidle')
-rw-r--r--drivers/cpuidle/cpuidle.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index 3e146b2ada4a..a71376a45d8e 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -74,7 +74,7 @@ static cpuidle_enter_t cpuidle_enter_ops;
/**
* cpuidle_play_dead - cpu off-lining
*
- * Only returns in case of an error
+ * Returns in case of an error or no driver
*/
int cpuidle_play_dead(void)
{
@@ -83,6 +83,9 @@ int cpuidle_play_dead(void)
int i, dead_state = -1;
int power_usage = -1;
+ if (!drv)
+ return -ENODEV;
+
/* Find lowest-power state that supports long-term idle */
for (i = CPUIDLE_DRIVER_STATE_START; i < drv->state_count; i++) {
struct cpuidle_state *s = &drv->states[i];