Commit fe1c06ca authored by Li Zefan's avatar Li Zefan Committed by Tejun Heo

cgroup: initialize cgrp->dentry before css_alloc()

With this change, we're guaranteed that cgroup_path() won't see NULL
cgrp->dentry, and thus we can remove the NULL check in it.

(Well, it's not strictly true, because dummptop.dentry is always NULL
 but we already handle that separately.)
Signed-off-by: default avatarLi Zefan <lizefan@huawei.com>
Signed-off-by: default avatarTejun Heo <tj@kernel.org>
parent b5d646f5
...@@ -1767,7 +1767,7 @@ int cgroup_path(const struct cgroup *cgrp, char *buf, int buflen) ...@@ -1767,7 +1767,7 @@ int cgroup_path(const struct cgroup *cgrp, char *buf, int buflen)
rcu_lockdep_assert(rcu_read_lock_held() || cgroup_lock_is_held(), rcu_lockdep_assert(rcu_read_lock_held() || cgroup_lock_is_held(),
"cgroup_path() called without proper locking"); "cgroup_path() called without proper locking");
if (!dentry || cgrp == dummytop) { if (cgrp == dummytop) {
/* /*
* Inactive subsystems have no dentry for their root * Inactive subsystems have no dentry for their root
* cgroup * cgroup
...@@ -4153,6 +4153,9 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry, ...@@ -4153,6 +4153,9 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
init_cgroup_housekeeping(cgrp); init_cgroup_housekeeping(cgrp);
dentry->d_fsdata = cgrp;
cgrp->dentry = dentry;
cgrp->parent = parent; cgrp->parent = parent;
cgrp->root = parent->root; cgrp->root = parent->root;
cgrp->top_cgroup = parent->top_cgroup; cgrp->top_cgroup = parent->top_cgroup;
...@@ -4190,8 +4193,6 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry, ...@@ -4190,8 +4193,6 @@ static long cgroup_create(struct cgroup *parent, struct dentry *dentry,
lockdep_assert_held(&dentry->d_inode->i_mutex); lockdep_assert_held(&dentry->d_inode->i_mutex);
/* allocation complete, commit to creation */ /* allocation complete, commit to creation */
dentry->d_fsdata = cgrp;
cgrp->dentry = dentry;
list_add_tail(&cgrp->allcg_node, &root->allcg_list); list_add_tail(&cgrp->allcg_node, &root->allcg_list);
list_add_tail_rcu(&cgrp->sibling, &cgrp->parent->children); list_add_tail_rcu(&cgrp->sibling, &cgrp->parent->children);
root->number_of_cgroups++; root->number_of_cgroups++;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment