Skip to content

Commit 0341509

Browse files
Li ZefanJens Axboe
authored andcommitted
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: Li Zefan <lizf@cn.fujitsu.com> Acked-by: Vivek Goyal <vgoyal@redhat.com> Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
1 parent dcf097b commit 0341509

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

block/blk-cgroup.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,16 +286,16 @@ static void blkiocg_destroy(struct cgroup_subsys *subsys, struct cgroup *cgroup)
286286
static struct cgroup_subsys_state *
287287
blkiocg_create(struct cgroup_subsys *subsys, struct cgroup *cgroup)
288288
{
289-
struct blkio_cgroup *blkcg, *parent_blkcg;
289+
struct blkio_cgroup *blkcg;
290+
struct cgroup *parent = cgroup->parent;
290291

291-
if (!cgroup->parent) {
292+
if (!parent) {
292293
blkcg = &blkio_root_cgroup;
293294
goto done;
294295
}
295296

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

301301
blkcg = kzalloc(sizeof(*blkcg), GFP_KERNEL);

0 commit comments

Comments
 (0)