mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-29 05:44:11 +00:00
memcg: null dereference on allocation failure
The original code had a null dereference if alloc_percpu() failed. This
was introduced in commit 711d3d2c9b
("memcg: cpu hotplug aware percpu
count updates")
Signed-off-by: Dan Carpenter <error27@gmail.com>
Reviewed-by: Balbir Singh <balbir@linux.vnet.ibm.com>
Acked-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Acked-by: Daisuke Nishimura <nishimura@mxp.nes.nec.co.jp>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
1093736b3c
commit
d2e61b8dc9
1 changed files with 9 additions and 7 deletions
|
@ -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)
|
||||||
if (size < PAGE_SIZE)
|
goto out_free;
|
||||||
kfree(mem);
|
|
||||||
else
|
|
||||||
vfree(mem);
|
|
||||||
mem = NULL;
|
|
||||||
}
|
|
||||||
spin_lock_init(&mem->pcp_counter_lock);
|
spin_lock_init(&mem->pcp_counter_lock);
|
||||||
return mem;
|
return mem;
|
||||||
|
|
||||||
|
out_free:
|
||||||
|
if (size < PAGE_SIZE)
|
||||||
|
kfree(mem);
|
||||||
|
else
|
||||||
|
vfree(mem);
|
||||||
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue