Skip to contentSkip to conversation

sched: Avoid NULL dereference on sd_busy

tip:sched/urgent tip-bot for Peter Zijlstra 1 participant 1 message Nov 19, 2013 1 message not in the archive Scheduler

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Commit-ID:  42eb088ed246a5a817bb45a8b32fe234cf1c0f8b
Gitweb:     http://git.kernel.org/tip/42eb088ed246a5a817bb45a8b32fe234cf1c0f8b
Author:     Peter Zijlstra <[email protected]>
AuthorDate: Tue, 19 Nov 2013 16:41:49 +0100
Committer:  Ingo Molnar <[email protected]>
CommitDate: Tue, 19 Nov 2013 17:01:16 +0100

sched: Avoid NULL dereference on sd_busy

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().

---
 kernel/sched/core.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
kernel/sched/core.c +2 -1
index c180860..a1591ca 100644
@@ -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;