Skip to content

Commit

Permalink
blk-cgroup: Fix an RCU warning in blkiocg_create()
Browse files Browse the repository at this point in the history
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: Li Zefan <[email protected]>
Acked-by: Vivek Goyal <[email protected]>
Signed-off-by: Jens Axboe <[email protected]>
  • Loading branch information
Li Zefan authored and Jens Axboe committed May 7, 2010
1 parent dcf097b commit 0341509
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions block/blk-cgroup.c
Original file line number Diff line number Diff line change
Expand Up @@ -286,16 +286,16 @@ static void blkiocg_destroy(struct cgroup_subsys *subsys, struct cgroup *cgroup)
static struct cgroup_subsys_state *
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;
goto done;
}

/* Currently we do not support hierarchy deeper than two level (0,1) */
parent_blkcg = cgroup_to_blkio_cgroup(cgroup->parent);
if (css_depth(&parent_blkcg->css) > 0)
if (parent != cgroup->top_cgroup)
return ERR_PTR(-EINVAL);

blkcg = kzalloc(sizeof(*blkcg), GFP_KERNEL);
Expand Down

0 comments on commit 0341509

Please sign in to comment.