diff options
author | Daniel Fu <danifu@nvidia.com> | 2013-08-30 07:48:22 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-08-30 15:53:41 -0400 |
commit | 3b9c10e98021e1f92e6f8c7ce1778b86ba68db10 (patch) | |
tree | e8c2963b4d5a2c8d90836fc069256c733be54232 /drivers/cpuidle/driver.c | |
parent | 9e19b73c30a5fa42a53583a1f7817dd857126156 (diff) |
cpuidle: Check the result of cpuidle_get_driver() against NULL
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 <danifu@nvidia.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/cpuidle/driver.c')
-rw-r--r-- | drivers/cpuidle/driver.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/cpuidle/driver.c b/drivers/cpuidle/driver.c index 3ac499d5a207..6e11701f0fca 100644 --- a/drivers/cpuidle/driver.c +++ b/drivers/cpuidle/driver.c | |||
@@ -331,7 +331,8 @@ struct cpuidle_driver *cpuidle_driver_ref(void) | |||
331 | spin_lock(&cpuidle_driver_lock); | 331 | spin_lock(&cpuidle_driver_lock); |
332 | 332 | ||
333 | drv = cpuidle_get_driver(); | 333 | drv = cpuidle_get_driver(); |
334 | drv->refcnt++; | 334 | if (drv) |
335 | drv->refcnt++; | ||
335 | 336 | ||
336 | spin_unlock(&cpuidle_driver_lock); | 337 | spin_unlock(&cpuidle_driver_lock); |
337 | return drv; | 338 | return drv; |