]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
percpu: fix a memory leak in pcpu_extend_area_map()
authorHuang Shijie <shijie8@gmail.com>
Sun, 8 Aug 2010 12:39:07 +0000 (14:39 +0200)
committerTejun Heo <tj@kernel.org>
Fri, 27 Aug 2010 09:36:08 +0000 (11:36 +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>
Cc: stable@kernel.org
mm/percpu.c

index e61dc2cc5873d7d89efc45609a4f4f2a8ae75732..a1830d8e33188a25b1d4fc9c8c22ea282577be20 100644 (file)
@@ -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;