Commit a8f531eb authored by Libin's avatar Libin Committed by Linus Torvalds
Browse files

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.

	vma = find_vma(mm, address)
Signed-off-by: default avatarLibin <>
Acked-by: default avatarKirill A. Shutemov <>
Reviewed-by: default avatarWanpeng Li <>
Reviewed-by: default avatarMichal Hocko <>
Cc: <> # v3.0+
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent e2d0bd2b
......@@ -2296,6 +2296,8 @@ static void collapse_huge_page(struct mm_struct *mm,
goto out;
vma = find_vma(mm, address);
if (!vma)
goto out;
hstart = (vma->vm_start + ~HPAGE_PMD_MASK) & HPAGE_PMD_MASK;
hend = vma->vm_end & HPAGE_PMD_MASK;
if (address < hstart || address + HPAGE_PMD_SIZE > hend)
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