memcg: avoid dangling reference count in creation failure. When use_hierarchy is enabled, we acquire an extra reference count in our parent during cgroup creation. We don't release it, though, if any failure exist in the creation process. Signed-off-by: Glauber Costa <glommer@parallels.com> Reported-by: Michal Hocko <mhocko@suse>
diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 4f61e79..f1d6670 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c
@@ -6166,6 +6166,8 @@ * call __mem_cgroup_free, so return directly */ mem_cgroup_put(memcg); + if (parent->use_hierarchy) + mem_cgroup_put(parent); } return error; }