Skip to content

Commit

Permalink
memcontrol: fix potential null deref
Browse files Browse the repository at this point in the history
There was a potential null deref introduced in c62b1a3 ("memcg: use
generic percpu instead of private implementation").

Signed-off-by: Dan Carpenter <error27@gmail.com>
Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Dan Carpenter authored and Linus Torvalds committed Mar 24, 2010
1 parent 9d34706 commit e7bbcdf
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions mm/memcontrol.c
Original file line number Diff line number Diff line change
Expand Up @@ -3691,8 +3691,10 @@ static struct mem_cgroup *mem_cgroup_alloc(void)
else
mem = vmalloc(size);

if (mem)
memset(mem, 0, size);
if (!mem)
return NULL;

memset(mem, 0, size);
mem->stat = alloc_percpu(struct mem_cgroup_stat_cpu);
if (!mem->stat) {
if (size < PAGE_SIZE)
Expand Down

0 comments on commit e7bbcdf

Please sign in to comment.