diff mbox series

[3/3] ublk_drv: missing error code in ublk_add_dev()

Message ID YtVAlDAfLLRolN/X@kili (mailing list archive)
State New, archived
Headers show
Series [1/3] ublk_drv: fix an IS_ERR() vs NULL check | expand

Commit Message

Dan Carpenter July 18, 2022, 11:14 a.m. UTC
This error path accidentally returns success instead of a negative
error code.

Fixes: cebbe577cb17 ("ublk_drv: fix request queue leak")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/block/ublk_drv.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Ming Lei July 18, 2022, 12:24 p.m. UTC | #1
On Mon, Jul 18, 2022 at 02:14:28PM +0300, Dan Carpenter wrote:
> This error path accidentally returns success instead of a negative
> error code.
> 
> Fixes: cebbe577cb17 ("ublk_drv: fix request queue leak")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  drivers/block/ublk_drv.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
> index c0f9a5b4ed58..332472901ff8 100644
> --- a/drivers/block/ublk_drv.c
> +++ b/drivers/block/ublk_drv.c
> @@ -1169,8 +1169,10 @@ static int ublk_add_dev(struct ublk_device *ub)
>  		goto out_deinit_queues;
>  
>  	ub->ub_queue = blk_mq_init_queue(&ub->tag_set);
> -	if (IS_ERR(ub->ub_queue))
> +	if (IS_ERR(ub->ub_queue)) {
> +		err = PTR_ERR(ub->ub_queue);
>  		goto out_cleanup_tags;
> +	}

Yang Yingliang has posted one same patch:

https://lore.kernel.org/linux-block/YtUOhUXBKG28bew4@T590/T/#t


Thanks,
Ming
diff mbox series

Patch

diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
index c0f9a5b4ed58..332472901ff8 100644
--- a/drivers/block/ublk_drv.c
+++ b/drivers/block/ublk_drv.c
@@ -1169,8 +1169,10 @@  static int ublk_add_dev(struct ublk_device *ub)
 		goto out_deinit_queues;
 
 	ub->ub_queue = blk_mq_init_queue(&ub->tag_set);
-	if (IS_ERR(ub->ub_queue))
+	if (IS_ERR(ub->ub_queue)) {
+		err = PTR_ERR(ub->ub_queue);
 		goto out_cleanup_tags;
+	}
 	ub->ub_queue->queuedata = ub;
 
 	disk = ub->ub_disk = blk_mq_alloc_disk_for_queue(ub->ub_queue,