Linux Power Management development
 help / color / mirror / Atom feed
* [PATCH] cpuidle: Check cpuidle driver before add refcount
@ 2013-08-30 11:48 Daniel Fu
  2013-08-30 12:01 ` Rafael J. Wysocki
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Fu @ 2013-08-30 11:48 UTC (permalink / raw)
  To: rjw, daniel.lezcano; +Cc: linux-pm, linux-kernel, joqiu, Daniel Fu

If the current CPU has no cpuidle driver, drv will be NULL.
Check if we get drv successfully before add refount
to prevent Kernel panic.

Signed-off-by: Daniel Fu <danifu@nvidia.com>
---
 drivers/cpuidle/driver.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/cpuidle/driver.c b/drivers/cpuidle/driver.c
index 3ac499d..6e11701 100644
--- a/drivers/cpuidle/driver.c
+++ b/drivers/cpuidle/driver.c
@@ -331,7 +331,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;
-- 
1.8.1.5


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-08-30 19:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-30 11:48 [PATCH] cpuidle: Check cpuidle driver before add refcount Daniel Fu
2013-08-30 12:01 ` Rafael J. Wysocki
2013-08-30 12:26   ` Daniel Fu
2013-08-30 13:25     ` Rafael J. Wysocki
2013-08-30 13:39       ` Daniel Fu
2013-08-30 19:51         ` Rafael J. Wysocki

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox