]> git.itanic.dy.fi Git - linux-stable/commitdiff
blk-cgroup: fix error unwinding in blkcg_init_queue
authorChristoph Hellwig <hch@lst.de>
Wed, 21 Sep 2022 18:04:45 +0000 (20:04 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 4 Jan 2023 10:26:22 +0000 (11:26 +0100)
[ Upstream commit 33dc62796cb657a633050138a86253fb2a553713 ]

When blk_throtl_init fails, we need to call blk_ioprio_exit.  Switch to
proper goto based unwinding to fix this.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Andreas Herrmann <aherrmann@suse.de>
Acked-by: Tejun Heo <tj@kernel.org>
Link: https://lore.kernel.org/r/20220921180501.1539876-2-hch@lst.de
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Stable-dep-of: 813e693023ba ("blk-iolatency: Fix memory leak on add_disk() failures")
Signed-off-by: Sasha Levin <sashal@kernel.org>
block/blk-cgroup.c

index c8f0c865bf4ede61d53ea86e4ee466a98251cccc..bcd3873ac5ff357721d1b965d16fe658d4da7aa5 100644 (file)
@@ -1297,17 +1297,18 @@ int blkcg_init_queue(struct request_queue *q)
 
        ret = blk_throtl_init(q);
        if (ret)
-               goto err_destroy_all;
+               goto err_ioprio_exit;
 
        ret = blk_iolatency_init(q);
-       if (ret) {
-               blk_throtl_exit(q);
-               blk_ioprio_exit(q);
-               goto err_destroy_all;
-       }
+       if (ret)
+               goto err_throtl_exit;
 
        return 0;
 
+err_throtl_exit:
+       blk_throtl_exit(q);
+err_ioprio_exit:
+       blk_ioprio_exit(q);
 err_destroy_all:
        blkg_destroy_all(q);
        return ret;