Skip to content

Commit

Permalink
mm/mremap.c: call pud_free() after fail calling pmd_alloc()
Browse files Browse the repository at this point in the history
In alloc_new_pmd(), if pud_alloc() was called successfully, but
pmd_alloc() fails, avoid leaking `pud'.

Signed-off-by: Chen Gang <gang.chen@asianux.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Chen Gang authored and Linus Torvalds committed Sep 11, 2013
1 parent 762216a commit 1ecfd53
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion mm/mremap.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <asm/uaccess.h>
#include <asm/cacheflush.h>
#include <asm/tlbflush.h>
#include <asm/pgalloc.h>

#include "internal.h"

Expand Down Expand Up @@ -62,8 +63,10 @@ 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)
if (!pmd) {
pud_free(mm, pud);
return NULL;
}

VM_BUG_ON(pmd_trans_huge(*pmd));

Expand Down

0 comments on commit 1ecfd53

Please sign in to comment.