mm: hpa: fix reference to NULL task_struct
authorCho KyongHo <pullip.cho@samsung.com>
Fri, 6 Apr 2018 12:05:25 +0000 (21:05 +0900)
committerhskang <hs1218.kang@samsung.com>
Mon, 27 Aug 2018 07:23:49 +0000 (16:23 +0900)
hpa_killer() finds the task with the largest oom_adj_score. It
repeatedly holds and releases references to the tasks during traversing
the list of tasks.
But it forgot the fact that selected that holds the pointer to the
task with the largest oom_adj_score for now is initialized by NULL.

Change-Id: Id374a8d5e2b1bbefc797a314f4eb36783258bbb1
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
mm/hpa.c

index 026c2b21a4f651663f78d6cd15d57b86d846daa3..7409a6ce825424ec3ad47a8b9587312ab97714cb 100644 (file)
--- a/mm/hpa.c
+++ b/mm/hpa.c
@@ -101,7 +101,9 @@ static int hpa_killer(void)
                    (tasksize <= selected_tasksize))
                        continue;
 
-               put_task_struct(selected);
+               if (selected)
+                       put_task_struct(selected);
+
                selected = p;
                selected_tasksize = tasksize;
                selected_adj = current_adj;