From: Michal Hocko Date: Fri, 13 Jan 2012 01:18:50 +0000 (-0800) Subject: memcg: free entries in soft_limit_tree if allocation fails X-Git-Url: https://openfabrics.org/gitweb/?a=commitdiff_plain;h=c3cecc683446ad54ca587d7123bd3ce94bd7b8e1;p=~shefty%2Frdma-dev.git memcg: free entries in soft_limit_tree if allocation fails If we are not able to allocate tree nodes for all NUMA nodes then we should release those that were allocated. Signed-off-by: Michal Hocko Acked-by: Johannes Weiner Cc: Michal Hocko Cc: Hugh Dickins Cc: Balbir Singh Cc: David Rientjes Cc: Andrea Arcangeli Cc: KAMEZAWA Hiroyuki Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 4c53e971749..2a1f7847b6a 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -4960,7 +4960,7 @@ static int mem_cgroup_soft_limit_tree_init(void) tmp = -1; rtpn = kzalloc_node(sizeof(*rtpn), GFP_KERNEL, tmp); if (!rtpn) - return 1; + goto err_cleanup; soft_limit_tree.rb_tree_per_node[node] = rtpn; @@ -4971,6 +4971,16 @@ static int mem_cgroup_soft_limit_tree_init(void) } } return 0; + +err_cleanup: + for_each_node_state(node, N_POSSIBLE) { + if (!soft_limit_tree.rb_tree_per_node[node]) + break; + kfree(soft_limit_tree.rb_tree_per_node[node]); + soft_limit_tree.rb_tree_per_node[node] = NULL; + } + return 1; + } static struct cgroup_subsys_state * __ref