[PATCH] percpu: Fix memory leak from percpu_init_late()

From: Catalin Marinas
Date: Thu Aug 19 2010 - 10:50:14 EST


The chunk->map memory block allocated in percpu_init_late() (as of
commit 099a19d9) is later overridden in pcpu_extend_area_map(). The
patch frees this existing block in the latter function. Found by
kmemleak.

Signed-off-by: Catalin Marinas <catalin.marinas@xxxxxxx>
Cc: Tejun Heo <tj@xxxxxxxxxx>
---
mm/percpu.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/mm/percpu.c b/mm/percpu.c
index e61dc2c..c0d3329 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -394,6 +394,7 @@ static int pcpu_extend_area_map(struct pcpu_chunk *chunk, int new_alloc)

old_size = chunk->map_alloc * sizeof(chunk->map[0]);
memcpy(new, chunk->map, old_size);
+ pcpu_mem_free(chunk->map, old_size);

chunk->map_alloc = new_alloc;
chunk->map = new;

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