sched: Avoid NULL dereference on sd_busy
authorPeter Zijlstra <[email protected]>
Tue, 19 Nov 2013 15:41:49 +0000 (16:41 +0100)
committerIngo Molnar <[email protected]>
Tue, 19 Nov 2013 16:01:16 +0000 (17:01 +0100)
Commit 37dc6b50cee9 ("sched: Remove unnecessary iteration over sched
domains to update nr_busy_cpus") forgot to clear 'sd_busy' under some
conditions leading to a possible NULL deref in set_cpu_sd_state_idle().

Reported-by: Anton Blanchard <[email protected]>
Cc: Preeti U Murthy <[email protected]>
Signed-off-by: Peter Zijlstra <[email protected]>
Link: http://lkml.kernel.org/r/[email protected]
Signed-off-by: Ingo Molnar <[email protected]>
kernel/sched/core.c

index c1808606ee5f0f4e48e2fc51380369ba248bd9fe..a1591ca7eb5ad9eadd13312ab55f5cfdfa3c40b7 100644 (file)
@@ -4910,8 +4910,9 @@ static void update_top_cache_domain(int cpu)
        if (sd) {
                id = cpumask_first(sched_domain_span(sd));
                size = cpumask_weight(sched_domain_span(sd));
-               rcu_assign_pointer(per_cpu(sd_busy, cpu), sd->parent);
+               sd = sd->parent; /* sd_busy */
        }
+       rcu_assign_pointer(per_cpu(sd_busy, cpu), sd);
 
        rcu_assign_pointer(per_cpu(sd_llc, cpu), sd);
        per_cpu(sd_llc_size, cpu) = size;