mm/huge_memory.c: fix potential NULL pointer dereference
authorLibin <[email protected]>
Wed, 11 Sep 2013 21:20:38 +0000 (14:20 -0700)
committerLinus Torvalds <[email protected]>
Wed, 11 Sep 2013 22:57:19 +0000 (15:57 -0700)
commita8f531ebc33052642b4bd7b812eedf397108ce64
treeeed956b9a3e7efa02937d984ae3f8d94810a478d
parente2d0bd2b924d74d5e0d4f395f8f4730d125e198c
mm/huge_memory.c: fix potential NULL pointer dereference

In collapse_huge_page() there is a race window between releasing the
mmap_sem read lock and taking the mmap_sem write lock, so find_vma() may
return NULL.  So check the return value to avoid NULL pointer dereference.

collapse_huge_page
khugepaged_alloc_page
up_read(&mm->mmap_sem)
down_write(&mm->mmap_sem)
vma = find_vma(mm, address)

Signed-off-by: Libin <[email protected]>
Acked-by: Kirill A. Shutemov <[email protected]>
Reviewed-by: Wanpeng Li <[email protected]>
Reviewed-by: Michal Hocko <[email protected]>
Cc: <[email protected]> # v3.0+
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
mm/huge_memory.c