linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] cpuidle: Avoid possible NULL pointer dereference in __cpuidle_register_device()
@ 2012-04-02 14:44 Srivatsa S. Bhat
  2012-04-02 19:31 ` Daniel Lezcano
  0 siblings, 1 reply; 8+ messages in thread
From: Srivatsa S. Bhat @ 2012-04-02 14:44 UTC (permalink / raw)
  To: lenb
  Cc: khilman, deepthi, g.trinabh, arjan, linux-kernel, linux-pm,
	Srivatsa S. Bhat, daniel.lezcano, amit.kucheria

In __cpuidle_register_device(), "dev->cpu" is used before checking if dev is
non-NULL. Fix it.

Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
---

 drivers/cpuidle/cpuidle.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/cpuidle/cpuidle.c b/drivers/cpuidle/cpuidle.c
index 87411ce..75b381e 100644
--- a/drivers/cpuidle/cpuidle.c
+++ b/drivers/cpuidle/cpuidle.c
@@ -372,7 +372,7 @@ EXPORT_SYMBOL_GPL(cpuidle_disable_device);
 static int __cpuidle_register_device(struct cpuidle_device *dev)
 {
 	int ret;
-	struct device *cpu_dev = get_cpu_device((unsigned long)dev->cpu);
+	struct device *cpu_dev;
 	struct cpuidle_driver *cpuidle_driver = cpuidle_get_driver();
 
 	if (!dev)
@@ -380,6 +380,7 @@ static int __cpuidle_register_device(struct cpuidle_device *dev)
 	if (!try_module_get(cpuidle_driver->owner))
 		return -EINVAL;
 
+	cpu_dev = get_cpu_device((unsigned long)dev->cpu);
 	init_completion(&dev->kobj_unregister);
 
 	per_cpu(cpuidle_devices, dev->cpu) = dev;


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

end of thread, other threads:[~2012-04-03 14:17 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-02 14:44 [PATCH] cpuidle: Avoid possible NULL pointer dereference in __cpuidle_register_device() Srivatsa S. Bhat
2012-04-02 19:31 ` Daniel Lezcano
2012-04-03 11:51   ` Srivatsa S. Bhat
2012-04-03 12:08     ` Daniel Lezcano
2012-04-03 13:15       ` Srivatsa S. Bhat
2012-04-03 13:51         ` Daniel Lezcano
2012-04-03 14:04           ` Srivatsa S. Bhat
2012-04-03 14:17             ` Daniel Lezcano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).