Linux Power Management development
 help / color / mirror / Atom feed
From: Daniel Fu <danifu@nvidia.com>
To: rjw@sisk.pl, daniel.lezcano@linaro.org
Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	joqiu@nvidia.com, Daniel Fu <danifu@nvidia.com>
Subject: [PATCH] cpuidle: Check cpuidle driver before add refcount
Date: Fri, 30 Aug 2013 19:48:22 +0800	[thread overview]
Message-ID: <1377863302-22465-1-git-send-email-danifu@nvidia.com> (raw)

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


             reply	other threads:[~2013-08-30 11:45 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-30 11:48 Daniel Fu [this message]
2013-08-30 12:01 ` [PATCH] cpuidle: Check cpuidle driver before add refcount 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1377863302-22465-1-git-send-email-danifu@nvidia.com \
    --to=danifu@nvidia.com \
    --cc=daniel.lezcano@linaro.org \
    --cc=joqiu@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=rjw@sisk.pl \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox