Skip to content

Commit

Permalink
mm: revert mremap pud_free anti-fix
Browse files Browse the repository at this point in the history
Revert commit 1ecfd53 ("mm/mremap.c: call pud_free() after fail
calling pmd_alloc()").

The original code was correct: pud_alloc(), pmd_alloc(), pte_alloc_map()
ensure that the pud, pmd, pt is already allocated, and seldom do they
need to allocate; on failure, upper levels are freed if appropriate by
the subsequent do_munmap().  Whereas commit 1ecfd53 did an
unconditional pud_free() of a most-likely still-in-use pud: saved only
by the near-impossiblity of pmd_alloc() failing.

Signed-off-by: Hugh Dickins <[email protected]>
Cc: Chen Gang <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Hugh Dickins authored and torvalds committed Oct 17, 2013
1 parent 750e816 commit 57a8f0c
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions mm/mremap.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include <asm/uaccess.h>
#include <asm/cacheflush.h>
#include <asm/tlbflush.h>
#include <asm/pgalloc.h>

#include "internal.h"

Expand Down Expand Up @@ -63,10 +62,8 @@ static pmd_t *alloc_new_pmd(struct mm_struct *mm, struct vm_area_struct *vma,
return NULL;

pmd = pmd_alloc(mm, pud, addr);
if (!pmd) {
pud_free(mm, pud);
if (!pmd)
return NULL;
}

VM_BUG_ON(pmd_trans_huge(*pmd));

Expand Down

0 comments on commit 57a8f0c

Please sign in to comment.