Skip to content

Commit

Permalink
cpuidle: Fix panic in CPU off-lining with no idle driver
Browse files Browse the repository at this point in the history
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 <[email protected]>
Cc: Boris Ostrovsky <[email protected]>
Reviewed-by: Srivatsa S. Bhat <[email protected]>
Tested-by: Srivatsa S. Bhat <[email protected]>
Signed-off-by: Len Brown <[email protected]>
  • Loading branch information
Toshi Kani authored and lenb committed Apr 6, 2012
1 parent 54f7007 commit ee01e66
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/cpuidle/cpuidle.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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];
Expand Down

0 comments on commit ee01e66

Please sign in to comment.