Commit 6e8b09ea authored by Sasha Levin's avatar Sasha Levin Committed by Linus Torvalds

mm: fix NULL ptr dereference in move_pages

Commit 3268c63e ("mm: fix move/migrate_pages() race on task struct") has
added an odd construct where 'mm' is checked for being NULL, and if it is,
it would get dereferenced anyways by mput()ing it.
Signed-off-by: default avatarSasha Levin <levinsasha928@gmail.com>
Cc: Dave Hansen <dave@linux.vnet.ibm.com>
Cc: Mel Gorman <mel@csn.ul.ie>
Cc: Johannes Weiner <hannes@cmpxchg.org>
Cc: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Cc: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Cc: Hugh Dickins <hughd@google.com>
Acked-by: default avatarChristoph Lameter <cl@linux.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent f2a9ef88
...@@ -1388,14 +1388,14 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages, ...@@ -1388,14 +1388,14 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
mm = get_task_mm(task); mm = get_task_mm(task);
put_task_struct(task); put_task_struct(task);
if (mm) { if (!mm)
if (nodes) return -EINVAL;
err = do_pages_move(mm, task_nodes, nr_pages, pages,
nodes, status, flags); if (nodes)
else err = do_pages_move(mm, task_nodes, nr_pages, pages,
err = do_pages_stat(mm, nr_pages, pages, status); nodes, status, flags);
} else else
err = -EINVAL; err = do_pages_stat(mm, nr_pages, pages, status);
mmput(mm); mmput(mm);
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment