vm: fix incorrect unlock error path in madvise_free_huge_pmd
authorLinus Torvalds <torvalds@linux-foundation.org>
Mon, 18 Jan 2016 02:33:15 +0000 (18:33 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Mon, 18 Jan 2016 02:33:15 +0000 (18:33 -0800)
Commit b8d3c4c3009d ("mm/huge_memory.c: don't split THP page when
MADV_FREE syscall is called") introduced this new function, but got the
error handling for when pmd_trans_huge_lock() fails wrong.  In the
failure case, the lock has not been taken, and we should not unlock on
the way out.

Cc: Minchan Kim <minchan@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
mm/huge_memory.c

index b2db98136af9d574646ef3f25d3cf1d462c174c1..50342eff796043e8e6c3daaac27c7c3779614a20 100644 (file)
@@ -1561,7 +1561,7 @@ int madvise_free_huge_pmd(struct mmu_gather *tlb, struct vm_area_struct *vma,
        int ret = 0;
 
        if (!pmd_trans_huge_lock(pmd, vma, &ptl))
-               goto out;
+               goto out_unlocked;
 
        orig_pmd = *pmd;
        if (is_huge_zero_pmd(orig_pmd)) {