diff mbox series

[01/17] blk-cgroup: fix error unwinding in blkcg_init_queue

Message ID 20220921180501.1539876-2-hch@lst.de (mailing list archive)
State New, archived
Headers show
Series [01/17] blk-cgroup: fix error unwinding in blkcg_init_queue | expand

Commit Message

Christoph Hellwig Sept. 21, 2022, 6:04 p.m. UTC
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>
---
 block/blk-cgroup.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

Comments

Andreas Herrmann Sept. 22, 2022, 1 p.m. UTC | #1
On Wed, Sep 21, 2022 at 08:04:45PM +0200, Christoph Hellwig wrote:
> 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>
> ---
>  block/blk-cgroup.c | 13 +++++++------
>  1 file changed, 7 insertions(+), 6 deletions(-)

Reviewed-by: Andreas Herrmann <aherrmann@suse.de>

> diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
> index 869af9d72bcf8..3a88f8c011d27 100644
> --- a/block/blk-cgroup.c
> +++ b/block/blk-cgroup.c
> @@ -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;
> -- 
> 2.30.2
>
diff mbox series

Patch

diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 869af9d72bcf8..3a88f8c011d27 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -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;