summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSasha Levin <levinsasha928@gmail.com>2012-04-25 16:01:53 -0700
committerBen Hutchings <ben@decadent.org.uk>2017-09-15 18:30:57 +0100
commit125a66961a14d740fe1a0a5398c2aaf7f715d17e (patch)
tree8af6eb97f89ca6931648151a4a3065bca9a86de5
parentd4f17eb3675ae072732a2dec54a450e7a3be05dd (diff)
mm: fix NULL ptr dereference in move_pages
commit 6e8b09eaf268bceac0c62e389b4bc0cb83dfb8e5 upstream. Commit 3268c63 ("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: Sasha 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: Christoph Lameter <cl@linux.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
-rw-r--r--mm/migrate.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/mm/migrate.c b/mm/migrate.c
index 2114bfcea76c..0f2736b319de 100644
--- a/mm/migrate.c
+++ b/mm/migrate.c
@@ -1412,14 +1412,14 @@ SYSCALL_DEFINE6(move_pages, pid_t, pid, unsigned long, nr_pages,
mm = get_task_mm(task);
put_task_struct(task);
- if (mm) {
- if (nodes)
- err = do_pages_move(mm, task_nodes, nr_pages, pages,
- nodes, status, flags);
- else
- err = do_pages_stat(mm, nr_pages, pages, status);
- } else
- err = -EINVAL;
+ if (!mm)
+ return -EINVAL;
+
+ if (nodes)
+ err = do_pages_move(mm, task_nodes, nr_pages, pages,
+ nodes, status, flags);
+ else
+ err = do_pages_stat(mm, nr_pages, pages, status);
mmput(mm);
return err;