Skip to contentSkip to conversation

mm/mremap.c: call pud_free() after fail calling pmd_alloc()

PATCH New Chen Gang 1 participant 1 message Aug 20, 2013

Subsystems (2)
lore
Share & tools
lore

Chen Gang

author
#0 lore raw

PATCH 1/1 mm/mremap.c: call pud_free() after fail calling pmd_alloc()

In alloc_new_pmd(), if pud_alloc() was called successfully, but pmd_alloc() is called by fail, in this case, need call pud_free() before return.

Also need include "asm/pgalloc.h" which have the declaration of pud_free(), or can not pass compiling.

---
 mm/mremap.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
mm/mremap.c +4 -1
index 457d34e..f37f8a0 100644
@@ -24,6 +24,7 @@
 #include <asm/uaccess.h>
 #include <asm/cacheflush.h>
 #include <asm/tlbflush.h>
+#include <asm/pgalloc.h>
 
 #include "internal.h"
 
@@ -61,8 +62,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));
 
Signature · 7 lines
1.7.7.6

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>