Skip to content

Commit

Permalink
device_cgroup: remove direct access to cgroup->children
Browse files Browse the repository at this point in the history
Currently, devcg::has_children() directly tests cgroup->children for
list emptiness.  The field is not a published field and scheduled to
go away.  In addition, the test isn't strictly correct as devcg should
only care about children which are visible to userland.

This patch converts has_children() to use css_next_child() instead.
The subtle incorrectness is noted and will be dealt with later.

Signed-off-by: Tejun Heo <[email protected]>
Acked-by: Aristeu Rozanski <[email protected]>
Acked-by: Serge Hallyn <[email protected]>
Acked-by: Li Zefan <[email protected]>
  • Loading branch information
htejun committed May 16, 2014
1 parent ea280e7 commit 5877019
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions security/device_cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -589,9 +589,17 @@ static int propagate_exception(struct dev_cgroup *devcg_root,

static inline bool has_children(struct dev_cgroup *devcgroup)
{
struct cgroup *cgrp = devcgroup->css.cgroup;
bool ret;

return !list_empty(&cgrp->children);
/*
* FIXME: There may be lingering offline csses and this function
* may return %true when there isn't any userland-visible child
* which is incorrect for our purposes.
*/
rcu_read_lock();
ret = css_next_child(NULL, &devcgroup->css);
rcu_read_unlock();
return ret;
}

/*
Expand Down

0 comments on commit 5877019

Please sign in to comment.