summaryrefslogtreecommitdiff
path: root/kernel
diff options
context:
space:
mode:
authorChris Redpath <chris.redpath@arm.com>2015-03-12 20:10:45 +0900
committerSeung-Woo Kim <sw0312.kim@samsung.com>2016-12-14 13:42:01 +0900
commit99b61b9a7433f8c1ee2713217dd454b3176e75f6 (patch)
treed3d707ef544affca4dfa9adfa2ed034b4ba54401 /kernel
parent2d70be8ea6158a1d08182535617f8fab8eed32be (diff)
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 <chris.redpath@arm.com>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/sched/fair.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c
index 7f05e5584265..33a6cdf9be0a 100644
--- a/kernel/sched/fair.c
+++ b/kernel/sched/fair.c
@@ -5946,7 +5946,11 @@ unlock:
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;