Skip to content

Commit c3cecc6

Browse files
Michal Hockotorvalds
authored andcommitted
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 <[email protected]> Acked-by: Johannes Weiner <[email protected]> Cc: Michal Hocko <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: Balbir Singh <[email protected]> Cc: David Rientjes <[email protected]> Cc: Andrea Arcangeli <[email protected]> Cc: KAMEZAWA Hiroyuki <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 9fb4b7c commit c3cecc6

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

mm/memcontrol.c

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4960,7 +4960,7 @@ static int mem_cgroup_soft_limit_tree_init(void)
49604960
tmp = -1;
49614961
rtpn = kzalloc_node(sizeof(*rtpn), GFP_KERNEL, tmp);
49624962
if (!rtpn)
4963-
return 1;
4963+
goto err_cleanup;
49644964

49654965
soft_limit_tree.rb_tree_per_node[node] = rtpn;
49664966

@@ -4971,6 +4971,16 @@ static int mem_cgroup_soft_limit_tree_init(void)
49714971
}
49724972
}
49734973
return 0;
4974+
4975+
err_cleanup:
4976+
for_each_node_state(node, N_POSSIBLE) {
4977+
if (!soft_limit_tree.rb_tree_per_node[node])
4978+
break;
4979+
kfree(soft_limit_tree.rb_tree_per_node[node]);
4980+
soft_limit_tree.rb_tree_per_node[node] = NULL;
4981+
}
4982+
return 1;
4983+
49744984
}
49754985

49764986
static struct cgroup_subsys_state * __ref

0 commit comments

Comments
 (0)