Commit e7bbcdf3747e3919c31cfa87853c69d178bce548
Committed by
Linus Torvalds
1 parent
9d34706f42
Exists in
master
and in
4 other branches
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 <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>
Showing 1 changed file with 4 additions and 2 deletions Side-by-side Diff
mm/memcontrol.c
... | ... | @@ -3691,8 +3691,10 @@ |
3691 | 3691 | else |
3692 | 3692 | mem = vmalloc(size); |
3693 | 3693 | |
3694 | - if (mem) | |
3695 | - memset(mem, 0, size); | |
3694 | + if (!mem) | |
3695 | + return NULL; | |
3696 | + | |
3697 | + memset(mem, 0, size); | |
3696 | 3698 | mem->stat = alloc_percpu(struct mem_cgroup_stat_cpu); |
3697 | 3699 | if (!mem->stat) { |
3698 | 3700 | if (size < PAGE_SIZE) |