[PATCH] x86: add missing free_memtype if get_vm_area_caller failed

From: Xiaotian Feng
Date: Wed Nov 04 2009 - 01:48:48 EST


When __ioremap_caller goes into get_vm_area, kernel already reserved
memtype. so if get_vm_area fails, we need to free it before return.

Signed-off-by: Xiaotian Feng <dfeng@xxxxxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: Ingo Molnar <mingo@xxxxxxxxxx>
Cc: H. Peter Anvin <hpa@xxxxxxxxx>
Cc: Venkatesh Pallipadi <venkatesh.pallipadi@xxxxxxxxx>
Cc: Suresh Siddha <suresh.b.siddha@xxxxxxxxx>
---
arch/x86/mm/ioremap.c | 4 +++-
1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
index 334e63c..7859f77 100644
--- a/arch/x86/mm/ioremap.c
+++ b/arch/x86/mm/ioremap.c
@@ -196,8 +196,10 @@ static void __iomem *__ioremap_caller(resource_size_t phys_addr,
* Ok, go for it..
*/
area = get_vm_area_caller(size, VM_IOREMAP, caller);
- if (!area)
+ if (!area) {
+ free_memtype(phys_addr, phys_addr + size);
return NULL;
+ }
area->phys_addr = phys_addr;
vaddr = (unsigned long) area->addr;

--
1.6.2.5

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/