Skip to content

Commit 15c3010

Browse files
YuKuai-huaweiaxboe
authored andcommitted
blk-cgroup: fix missing put device in error path from blkg_conf_pref()
If blk_queue_enter() failed due to queue is dying, the blkdev_put_no_open() is needed because blkcg_conf_open_bdev() succeeded. Fixes: 0c9d338 ("blk-cgroup: synchronize blkg creation against policy deactivation") Signed-off-by: Yu Kuai <yukuai3@huawei.com> Acked-by: Tejun Heo <tj@kernel.org> Link: https://lore.kernel.org/r/20211102020705.2321858-1-yukuai3@huawei.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 245a489 commit 15c3010

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

block/blk-cgroup.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
640640
*/
641641
ret = blk_queue_enter(q, 0);
642642
if (ret)
643-
return ret;
643+
goto fail;
644644

645645
rcu_read_lock();
646646
spin_lock_irq(&q->queue_lock);
@@ -676,13 +676,13 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
676676
new_blkg = blkg_alloc(pos, q, GFP_KERNEL);
677677
if (unlikely(!new_blkg)) {
678678
ret = -ENOMEM;
679-
goto fail;
679+
goto fail_exit_queue;
680680
}
681681

682682
if (radix_tree_preload(GFP_KERNEL)) {
683683
blkg_free(new_blkg);
684684
ret = -ENOMEM;
685-
goto fail;
685+
goto fail_exit_queue;
686686
}
687687

688688
rcu_read_lock();
@@ -722,9 +722,10 @@ int blkg_conf_prep(struct blkcg *blkcg, const struct blkcg_policy *pol,
722722
fail_unlock:
723723
spin_unlock_irq(&q->queue_lock);
724724
rcu_read_unlock();
725+
fail_exit_queue:
726+
blk_queue_exit(q);
725727
fail:
726728
blkdev_put_no_open(bdev);
727-
blk_queue_exit(q);
728729
/*
729730
* If queue was bypassing, we should retry. Do so after a
730731
* short msleep(). It isn't strictly necessary but queue

0 commit comments

Comments
 (0)