From: Michal Hocko Date: Fri, 1 Apr 2016 21:31:34 +0000 (-0700) Subject: oom, oom_reaper: do not enqueue task if it is on the oom_reaper_list head X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=af8e15cc85a253155fdcea707588bf6ddfc0be2e;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git oom, oom_reaper: do not enqueue task if it is on the oom_reaper_list head Commit bb29902a7515 ("oom, oom_reaper: protect oom_reaper_list using simpler way") has simplified the check for tasks already enqueued for the oom reaper by checking tsk->oom_reaper_list != NULL. This check is not sufficient because the tsk might be the head of the queue without any other tasks queued and then we would simply lockup looping on the same task. Fix the condition by checking for the head as well. Fixes: bb29902a7515 ("oom, oom_reaper: protect oom_reaper_list using simpler way") Signed-off-by: Michal Hocko Acked-by: Tetsuo Handa Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/oom_kill.c b/mm/oom_kill.c index b34d279a7ee6..86349586eacb 100644 --- a/mm/oom_kill.c +++ b/mm/oom_kill.c @@ -547,7 +547,11 @@ static int oom_reaper(void *unused) static void wake_oom_reaper(struct task_struct *tsk) { - if (!oom_reaper_th || tsk->oom_reaper_list) + if (!oom_reaper_th) + return; + + /* tsk is already queued? */ + if (tsk == oom_reaper_list || tsk->oom_reaper_list) return; get_task_struct(tsk);