From: Daniel Fu Date: Fri, 30 Aug 2013 11:48:22 +0000 (+0800) Subject: cpuidle: Check the result of cpuidle_get_driver() against NULL X-Git-Url: http://git.mmlx.us/?a=commitdiff_plain;h=6ae69a801bb987433282fc6c8c18fe60c1dae6b4;p=linux-edison.git cpuidle: Check the result of cpuidle_get_driver() against NULL commit 3b9c10e98021e1f92e6f8c7ce1778b86ba68db10 upstream. If the current CPU has no cpuidle driver, drv will be NULL in cpuidle_driver_ref(). Check if that is the case before trying to bump up the driver's refcount to prevent the kernel from crashing. [rjw: Subject and changelog] Signed-off-by: Daniel Fu Signed-off-by: Rafael J. Wysocki Cc: Mark Brown Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/cpuidle/driver.c b/drivers/cpuidle/driver.c index 8dfaaae9444..2253271b3fa 100644 --- a/drivers/cpuidle/driver.c +++ b/drivers/cpuidle/driver.c @@ -251,7 +251,8 @@ struct cpuidle_driver *cpuidle_driver_ref(void) spin_lock(&cpuidle_driver_lock); drv = cpuidle_get_driver(); - drv->refcnt++; + if (drv) + drv->refcnt++; spin_unlock(&cpuidle_driver_lock); return drv;