From: Johannes Weiner Date: Tue, 6 Jan 2009 22:40:31 +0000 (-0800) Subject: mm: check for no mmaps in exit_mmap() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=dcd4a049b9751828c516c59709f3fdf50436df85;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git 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 Reported-by: Akinobu Mita Cc: Nick Piggin Cc: Hugh Dickins Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/mmap.c b/mm/mmap.c index 1f97d8aa9b05..a910c045cfd4 100644 --- a/mm/mmap.c +++ b/mm/mmap.c @@ -2090,6 +2090,9 @@ void exit_mmap(struct mm_struct *mm) arch_exit_mmap(mm); mmu_notifier_release(mm); + if (!mm->mmap) /* Can happen if dup_mmap() received an OOM */ + return; + if (mm->locked_vm) { vma = mm->mmap; while (vma) {