diff --git a/mm/memcontrol.c b/mm/memcontrol.c index 5c3e2e3d27ac4f46a909e318b3efc5dab495240f..f06b5c249ecbd9a441906a88d13dffbdabfae18d 100644 --- a/mm/memcontrol.c +++ b/mm/memcontrol.c @@ -1065,15 +1065,10 @@ struct mem_cgroup *mem_cgroup_iter(struct mem_cgroup *root, * is provided by the caller, so we know it's alive * and kicking, and don't take an extra reference. */ - memcg = mem_cgroup_from_css(css); - - if (css == &root->css) - break; - - if (css_tryget(css)) + if (css == &root->css || css_tryget(css)) { + memcg = mem_cgroup_from_css(css); break; - - memcg = NULL; + } } if (reclaim) {