Skip to content

Commit

Permalink
percpu: fix a memory leak in pcpu_extend_area_map()
Browse files Browse the repository at this point in the history
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
  • Loading branch information
zyzii authored and htejun committed Aug 27, 2010
1 parent 94cb121 commit a002d14
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion mm/percpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit a002d14

Please sign in to comment.