Commit d2e61b8d authored by Dan Carpenter's avatar Dan Carpenter Committed by Linus Torvalds

memcg: null dereference on allocation failure

The original code had a null dereference if alloc_percpu() failed.  This
was introduced in commit 711d3d2c ("memcg: cpu hotplug aware percpu
count updates")
Signed-off-by: default avatarDan Carpenter <error27@gmail.com>
Reviewed-by: default avatarBalbir Singh <balbir@linux.vnet.ibm.com>
Acked-by: default avatarKAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Acked-by: default avatarDaisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 1093736b
...@@ -4208,15 +4208,17 @@ static struct mem_cgroup *mem_cgroup_alloc(void) ...@@ -4208,15 +4208,17 @@ static struct mem_cgroup *mem_cgroup_alloc(void)
memset(mem, 0, size); memset(mem, 0, size);
mem->stat = alloc_percpu(struct mem_cgroup_stat_cpu); mem->stat = alloc_percpu(struct mem_cgroup_stat_cpu);
if (!mem->stat) { if (!mem->stat)
goto out_free;
spin_lock_init(&mem->pcp_counter_lock);
return mem;
out_free:
if (size < PAGE_SIZE) if (size < PAGE_SIZE)
kfree(mem); kfree(mem);
else else
vfree(mem); vfree(mem);
mem = NULL; return NULL;
}
spin_lock_init(&mem->pcp_counter_lock);
return mem;
} }
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment