From: Dan Carpenter Date: Tue, 23 Mar 2010 20:35:12 +0000 (-0700) Subject: memcontrol: fix potential null deref X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=e7bbcdf3747e3919c31cfa87853c69d178bce548;p=deliverable%2Flinux.git memcontrol: fix potential null deref There was a potential null deref introduced in c62b1a3b31b5 ("memcg: use generic percpu instead of private implementation"). Signed-off-by: Dan Carpenter Acked-by: KAMEZAWA Hiroyuki Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 00dda352144c..9ed760dc7448 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -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)