From: Chris Redpath Date: Wed, 11 Jun 2014 13:08:40 +0000 (+0100) Subject: sched: hmp: fix out-of-range CPU possible X-Git-Tag: firefly_0821_release~3680^2~16^2^2~4 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=4378062f289e67259f017f6b176ee385dc974836;p=firefly-linux-kernel-4.4.55.git sched: hmp: fix out-of-range CPU possible If someone hotplugs all the little CPUs while another CPU is handling a wakeup, we can potentially return new_cpu == NR_CPUS from hmp_select_slower_cpu (which is called internally by hmp_best_little_cpu as well). We will use this to deref the per_cpu rq array in hmp_next_down_delay which can go boom. Signed-off-by: Chris Redpath Signed-off-by: Jon Medhurst --- diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index ffa643ce9116..26c43b463017 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c @@ -4456,7 +4456,11 @@ unlock: #else new_cpu = hmp_select_slower_cpu(p, prev_cpu); #endif - if (new_cpu != prev_cpu) { + /* + * we might have no suitable CPU + * in which case new_cpu == NR_CPUS + */ + if (new_cpu < NR_CPUS && new_cpu != prev_cpu) { hmp_next_down_delay(&p->se, new_cpu); trace_sched_hmp_migrate(p, new_cpu, HMP_MIGRATE_WAKEUP); return new_cpu;