Commit 0341509f authored by Li Zefan's avatar Li Zefan Committed by Jens Axboe

blk-cgroup: Fix an RCU warning in blkiocg_create()

with CONFIG_PROVE_RCU=y, a warning can be triggered:

  # mount -t cgroup -o blkio xxx /mnt
  # mkdir /mnt/subgroup

...
kernel/cgroup.c:4442 invoked rcu_dereference_check() without protection!
...

To fix this, we avoid caling css_depth() here, which is a bit simpler
than the original code.
Signed-off-by: default avatarLi Zefan <lizf@cn.fujitsu.com>
Acked-by: default avatarVivek Goyal <vgoyal@redhat.com>
Signed-off-by: default avatarJens Axboe <jens.axboe@oracle.com>
parent dcf097b2
...@@ -286,16 +286,16 @@ static void blkiocg_destroy(struct cgroup_subsys *subsys, struct cgroup *cgroup) ...@@ -286,16 +286,16 @@ static void blkiocg_destroy(struct cgroup_subsys *subsys, struct cgroup *cgroup)
static struct cgroup_subsys_state * static struct cgroup_subsys_state *
blkiocg_create(struct cgroup_subsys *subsys, struct cgroup *cgroup) blkiocg_create(struct cgroup_subsys *subsys, struct cgroup *cgroup)
{ {
struct blkio_cgroup *blkcg, *parent_blkcg; struct blkio_cgroup *blkcg;
struct cgroup *parent = cgroup->parent;
if (!cgroup->parent) { if (!parent) {
blkcg = &blkio_root_cgroup; blkcg = &blkio_root_cgroup;
goto done; goto done;
} }
/* Currently we do not support hierarchy deeper than two level (0,1) */ /* Currently we do not support hierarchy deeper than two level (0,1) */
parent_blkcg = cgroup_to_blkio_cgroup(cgroup->parent); if (parent != cgroup->top_cgroup)
if (css_depth(&parent_blkcg->css) > 0)
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
blkcg = kzalloc(sizeof(*blkcg), GFP_KERNEL); blkcg = kzalloc(sizeof(*blkcg), GFP_KERNEL);
......
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