From aef918d19a893b8bc375b113144c0a7b6cb48d16 Mon Sep 17 00:00:00 2001 From: Suren Baghdasaryan Date: Wed, 3 Feb 2021 15:26:09 -0800 Subject: [PATCH] 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 Change-Id: Id9a3f1b824c6a81d157782b8cb18115b3c577a50 --- mm/oom_kill.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/mm/oom_kill.c b/mm/oom_kill.c index e8f2ba403e97..b8e669567d9c 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -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 * 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); oc->chosen = oc->chosen_non_negative_adj; oc->chosen_points = oc->chosen_non_negative_adj_points;