Skip to content

Commit

Permalink
memcg: free entries in soft_limit_tree if allocation fails
Browse files Browse the repository at this point in the history
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 <mhocko@suse.cz>
Acked-by: Johannes Weiner <hannes@cmpxchg.org>
Cc: Michal Hocko <mhocko@suse.cz>
Cc: Hugh Dickins <hughd@google.com>
Cc: Balbir Singh <bsingharora@gmail.com>
Cc: David Rientjes <rientjes@google.com>
Cc: Andrea Arcangeli <aarcange@redhat.com>
Cc: 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>
  • Loading branch information
Michal Hocko authored and Linus Torvalds committed Jan 13, 2012
1 parent 9fb4b7c commit c3cecc6
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion mm/memcontrol.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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
Expand Down

0 comments on commit c3cecc6

Please sign in to comment.