Commit dcd4a049b9751828c516c59709f3fdf50436df85

Authored by Johannes Weiner
Committed by Linus Torvalds
1 parent 084f71ae5c

mm: check for no mmaps in exit_mmap()

When dup_mmap() ooms we can end up with mm->mmap == NULL.  The error
path does mmput() and unmap_vmas() gets a NULL vma which it
dereferences.

In exit_mmap() there is nothing to do at all for this case, we can
cancel the callpath right there.

[akpm@linux-foundation.org: add sorely-needed comment]
Signed-off-by: Johannes Weiner <hannes@cmpxchg.org>
Reported-by: Akinobu Mita <akinobu.mita@gmail.com>
Cc: Nick Piggin <nickpiggin@yahoo.com.au>
Cc: Hugh Dickins <hugh@veritas.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

Showing 1 changed file with 3 additions and 0 deletions Side-by-side Diff

... ... @@ -2090,6 +2090,9 @@
2090 2090 arch_exit_mmap(mm);
2091 2091 mmu_notifier_release(mm);
2092 2092  
  2093 + if (!mm->mmap) /* Can happen if dup_mmap() received an OOM */
  2094 + return;
  2095 +
2093 2096 if (mm->locked_vm) {
2094 2097 vma = mm->mmap;
2095 2098 while (vma) {