Commit 5fbbb90dfdedb9a258550e4e5debd3013266372e

Authored by Jon Medhurst (Tixy)
Committed by Rafael J. Wysocki
1 parent 63c6ba4352

cpuidle: Prevent null pointer dereference in cpuidle_coupled_cpu_notify

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>

Showing 1 changed file with 1 additions and 1 deletions Side-by-side Diff

drivers/cpuidle/coupled.c
... ... @@ -693,7 +693,7 @@
693 693 mutex_lock(&cpuidle_lock);
694 694  
695 695 dev = per_cpu(cpuidle_devices, cpu);
696   - if (!dev->coupled)
  696 + if (!dev || !dev->coupled)
697 697 goto out;
698 698  
699 699 switch (action & ~CPU_TASKS_FROZEN) {