ANDROID: mm, oom: Fix select_bad_process customization

Patch 'ANDROID: mm, oom: Avoid killing tasks with negative ADJ scores'
does not handle a special case when oom_evaluate_task is aborted and
sets oc->chosen to -1. Check for this condition to avoid invalid memory
access.

Bug: 179177151
Signed-off-by: Suren Baghdasaryan <surenb@google.com>
Change-Id: Id9a3f1b824c6a81d157782b8cb18115b3c577a50
This commit is contained in:
Suren Baghdasaryan
2021-02-03 15:26:09 -08:00
parent cf397c6c26
commit aef918d19a

View File

@@ -404,7 +404,8 @@ static void select_bad_process(struct oom_control *oc)
* a postive ADJ to kill, kill the task with the positive ADJ * a postive ADJ to kill, kill the task with the positive ADJ
* instead. * instead.
*/ */
if (oc->chosen && oc->chosen->signal->oom_score_adj < 0) { if (oc->chosen && oc->chosen != (void *)-1UL &&
oc->chosen->signal->oom_score_adj < 0) {
put_task_struct(oc->chosen); put_task_struct(oc->chosen);
oc->chosen = oc->chosen_non_negative_adj; oc->chosen = oc->chosen_non_negative_adj;
oc->chosen_points = oc->chosen_non_negative_adj_points; oc->chosen_points = oc->chosen_non_negative_adj_points;