Skip to content

Commit 5877019

Browse files
committed
device_cgroup: remove direct access to cgroup->children
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 <tj@kernel.org> Acked-by: Aristeu Rozanski <aris@redhat.com> Acked-by: Serge Hallyn <serge.hallyn@ubuntu.com> Acked-by: Li Zefan <lizefan@huawei.com>
1 parent ea280e7 commit 5877019

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

‎security/device_cgroup.c‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,9 +589,17 @@ static int propagate_exception(struct dev_cgroup *devcg_root,
589589

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

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

597605
/*

0 commit comments

Comments
 (0)