diff options
| author | John Dias <joaodias@google.com> | 2018-06-22 12:27:38 -0700 |
|---|---|---|
| committer | Pavankumar Kondeti <pkondeti@codeaurora.org> | 2018-08-08 09:09:01 +0530 |
| commit | bd4ac8e584ed7e2e79acc72afcdd63a4b6937327 (patch) | |
| tree | 895128d62882e689195754722f01e3c28b49871d /kernel | |
| parent | 42570c93eca94652aa82f2c880004789606bbbe7 (diff) | |
sched: walt: fix out-of-bounds access
A computation in update_top_tasks() is indexing
off the end of a top_tasks array. There's code
to limit the index in the computation, but it's
insufficient.
Bug: 110529282
Change-Id: Idb5ff5e5800c014394bcb04638844bf1e057a40c
Signed-off-by: John Dias <joaodias@google.com>
[pkondeti@codeaurora.org: Backported to 4.4 for HMP scheduler]
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
Diffstat (limited to 'kernel')
| -rw-r--r-- | kernel/sched/hmp.c | 11 |
1 files changed, 4 insertions, 7 deletions
diff --git a/kernel/sched/hmp.c b/kernel/sched/hmp.c index d9f0669ff683..ddcf7cfb7248 100644 --- a/kernel/sched/hmp.c +++ b/kernel/sched/hmp.c @@ -2081,14 +2081,11 @@ static u32 top_task_load(struct rq *rq) } } -static int load_to_index(u32 load) +static u32 load_to_index(u32 load) { - if (load < sched_load_granule) - return 0; - else if (load >= sched_ravg_window) - return NUM_LOAD_INDICES - 1; - else - return load / sched_load_granule; + u32 index = load / sched_load_granule; + + return min(index, (u32)(NUM_LOAD_INDICES - 1)); } static void update_top_tasks(struct task_struct *p, struct rq *rq, |
