From: KAMEZAWA Hiroyuki Date: Tue, 25 Jan 2011 23:07:27 +0000 (-0800) Subject: memcg: fix account leak at failure of memsw acconting X-Git-Tag: v2.6.36.4~56 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=ca4cf61868e2bafeeb9f320e5da9b431e0f3aabd;p=karo-tx-linux.git memcg: fix account leak at failure of memsw acconting commit 01c88e2d6b7330c0cc5867fe2297e7d826e1337d upstream. Commit 4b53433468 ("memcg: clean up try_charge main loop") removes a cancel of charge at case: memory charge-> success. mem+swap charge-> failure. This leaks usage of memory. Fix it. Signed-off-by: KAMEZAWA Hiroyuki Reviewed-by: Johannes Weiner Acked-by: Daisuke Nishimura Cc: Balbir Singh Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Greg Kroah-Hartman --- diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 0f900de4c676..a9a534a38ac0 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1647,6 +1647,7 @@ static int __mem_cgroup_do_charge(struct mem_cgroup *mem, gfp_t gfp_mask, if (likely(!ret)) return CHARGE_OK; + res_counter_uncharge(&mem->res, csize); mem_over_limit = mem_cgroup_from_res_counter(fail_res, memsw); flags |= MEM_CGROUP_RECLAIM_NOSWAP; } else