[PATCH] x86/pat: fix memory leak in free_memtype

From: Xiaotian Feng
Date: Tue May 25 2010 - 05:53:19 EST


reserve_memtype will allocate memory for new memtype, but
in free_memtype, after the memtype erased from rbtree, the
memory is not freed.

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: Jack Steiner <steiner@xxxxxxx>
Cc: Suresh Siddha <suresh.b.siddha@xxxxxxxxx>
---
arch/x86/mm/pat_rbtree.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/arch/x86/mm/pat_rbtree.c b/arch/x86/mm/pat_rbtree.c
index 07de4cb..fb8c1e5 100644
--- a/arch/x86/mm/pat_rbtree.c
+++ b/arch/x86/mm/pat_rbtree.c
@@ -15,6 +15,7 @@
#include <linux/rbtree.h>
#include <linux/sched.h>
#include <linux/gfp.h>
+#include <linux/slab.h>

#include <asm/pgtable.h>
#include <asm/pat.h>
@@ -240,6 +241,7 @@ int rbt_memtype_erase(u64 start, u64 end)
return -EINVAL;

rb_erase(&data->rb, &memtype_rbroot);
+ kfree(data);
return 0;
}

--
1.7.0.1

--
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/