Skip to content

Commit

Permalink
cgroup: fix cgroup post-order descendant walk of empty subtree
Browse files Browse the repository at this point in the history
bd8815a ("cgroup: make css_for_each_descendant() and friends
include the origin css in the iteration") updated cgroup descendant
iterators to include the origin css; unfortuantely, it forgot to drop
special case handling in css_next_descendant_post() for empty subtree
leading to failure to visit the origin css without any child.

Fix it by dropping the special case handling and always returning the
leftmost descendant on the first iteration.

Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: Li Zefan <lizefan@huawei.com>
  • Loading branch information
Tejun Heo committed Sep 10, 2013
1 parent 26b0332 commit 58b79a9
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions kernel/cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -3187,11 +3187,9 @@ css_next_descendant_post(struct cgroup_subsys_state *pos,

WARN_ON_ONCE(!rcu_read_lock_held());

/* if first iteration, visit the leftmost descendant */
if (!pos) {
next = css_leftmost_descendant(root);
return next != root ? next : NULL;
}
/* if first iteration, visit leftmost descendant which may be @root */
if (!pos)
return css_leftmost_descendant(root);

/* if we visited @root, we're done */
if (pos == root)
Expand Down

0 comments on commit 58b79a9

Please sign in to comment.