sched: Set curr/prev_window_cpu pointers to NULL in sched_exit()

trace_sched_update_task_ravg relies on NULL pointers to ensure that
it doesn't access them. Make sure that when a task exits, these
pointers are set to NULL. Otherwise any call to update_task_ravg()
between sched_exit() and releasing the task structure will access
bogus pointers. In some cases those memory locations are unmapped
and cause a kernel panic.

Change-Id: I9eebb4fb35aca2c8424bfb29ae9d833650dc5ad4
Signed-off-by: Syed Rameez Mustafa <rameezmustafa@codeaurora.org>
This commit is contained in:
Syed Rameez Mustafa 2016-10-24 18:37:14 -07:00
parent 46aa49c118
commit 5c647926d0

View file

@ -2273,6 +2273,14 @@ void sched_exit(struct task_struct *p)
kfree(p->ravg.curr_window_cpu);
kfree(p->ravg.prev_window_cpu);
/*
* update_task_ravg() can be called for exiting tasks. While the
* function itself ensures correct behavior, the corresponding
* trace event requires that these pointers be NULL.
*/
p->ravg.curr_window_cpu = NULL;
p->ravg.prev_window_cpu = NULL;
enqueue_task(rq, p, 0);
clear_ed_task(p, rq);
task_rq_unlock(rq, p, &flags);