]> rtime.felk.cvut.cz Git - linux-imx.git/commitdiff
cpuidle: Prevent null pointer dereference in cpuidle_coupled_cpu_notify
authorJon Medhurst (Tixy) <tixy@linaro.org>
Wed, 15 Aug 2012 20:11:00 +0000 (22:11 +0200)
committerRafael J. Wysocki <rjw@sisk.pl>
Fri, 17 Aug 2012 17:37:08 +0000 (19:37 +0200)
When a kernel is built to support multiple hardware types it's possible
that CONFIG_ARCH_NEEDS_CPU_IDLE_COUPLED is set but the hardware the
kernel is run on doesn't support cpuidle and therefore doesn't load a
driver for it. In this case, when the system is shut down,
cpuidle_coupled_cpu_notify() gets called with cpuidle_devices set to
NULL. There are quite possibly other circumstances where this
situation can also occur and we should check for it.

Signed-off-by: Jon Medhurst <tixy@linaro.org>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
drivers/cpuidle/coupled.c

index c24dda03c143eec8845c8162e155c2e0fde16067..3265844839bfe9c79ef8849705262a52d16cc4e1 100644 (file)
@@ -693,7 +693,7 @@ static int cpuidle_coupled_cpu_notify(struct notifier_block *nb,
        mutex_lock(&cpuidle_lock);
 
        dev = per_cpu(cpuidle_devices, cpu);
-       if (!dev->coupled)
+       if (!dev || !dev->coupled)
                goto out;
 
        switch (action & ~CPU_TASKS_FROZEN) {