From: Johannes Weiner Date: Thu, 31 Oct 2013 23:34:13 +0000 (-0700) Subject: mm: memcg: use proper memcg in limit bypass X-Git-Tag: MMI-PSA29.97-13-9~13380^2~3 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=3168ecbe1c04ec3feb7cb42388a17d7f047fe1a2;p=GitHub%2FMotorolaMobilityLLC%2Fkernel-slsi.git mm: memcg: use proper memcg in limit bypass Commit 84235de394d9 ("fs: buffer: move allocation failure loop into the allocator") allowed __GFP_NOFAIL allocations to bypass the limit if they fail to reclaim enough memory for the charge. But because the main test case was on a 3.2-based system, the patch missed the fact that on newer kernels the charge function needs to return root_mem_cgroup when bypassing the limit, and not NULL. This will corrupt whatever memory is at NULL + percpu pointer offset. Fix this quickly before problems are reported. Signed-off-by: Johannes Weiner Acked-by: Michal Hocko Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 497ec33ff22d..623d5c8bb1e1 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -2765,10 +2765,10 @@ done: *ptr = memcg; return 0; nomem: - *ptr = NULL; - if (gfp_mask & __GFP_NOFAIL) - return 0; - return -ENOMEM; + if (!(gfp_mask & __GFP_NOFAIL)) { + *ptr = NULL; + return -ENOMEM; + } bypass: *ptr = root_mem_cgroup; return -EINTR;