[PATCH] percpu: fix a memory leak in pcpu_extend_area_map()

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Tejun Heo
Date: Sunday, August 8, 2010 - 5:42 am

From 206c53730b8b1707becca7a868ea8d14ebee24d2 Mon Sep 17 00:00:00 2001
From: Huang Shijie <shijie8@gmail.com>
Date: Sun, 8 Aug 2010 14:39:07 +0200

The original code did not free the old map.  This patch fixes it.

tj: use @old as memcpy source instead of @chunk->map, and indentation
    and description update

Signed-off-by: Huang Shijie <shijie8@gmail.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
---
Patch applied to percpu#for-linus w/ some updates.  Thanks a lot for
catching this.

 mm/percpu.c |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/mm/percpu.c b/mm/percpu.c
index e61dc2c..a1830d8 100644
--- a/mm/percpu.c
+++ b/mm/percpu.c
@@ -393,7 +393,9 @@ static int pcpu_extend_area_map(struct pcpu_chunk *chunk, int new_alloc)
 		goto out_unlock;

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

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

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] percpu: fix a memory leak in pcpu_extend_area_map(), Tejun Heo, (Sun Aug 8, 5:42 am)
Re: [stable] breaks 2.6.32.21+, Tejun Heo, (Fri Sep 17, 6:47 am)
Re: [stable] breaks 2.6.32.21+, Greg KH, (Fri Sep 17, 9:36 am)