diff mbox series

[1/3] ublk_drv: fix an IS_ERR() vs NULL check

Message ID YtVAgedTsQVK1oTM@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
The blk_mq_alloc_disk_for_queue() doesn't return error pointers, it
returns NULL on error.

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, 2 insertions(+), 2 deletions(-)

Comments

Ming Lei July 18, 2022, 12:19 p.m. UTC | #1
On Mon, Jul 18, 2022 at 02:14:09PM +0300, Dan Carpenter wrote:
> The blk_mq_alloc_disk_for_queue() doesn't return error pointers, it
> returns NULL on error.
> 
> 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, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
> index 52fd0af8a4f2..97725d13e4bd 100644
> --- a/drivers/block/ublk_drv.c
> +++ b/drivers/block/ublk_drv.c
> @@ -1175,8 +1175,8 @@ static int ublk_add_dev(struct ublk_device *ub)
>  
>  	disk = ub->ub_disk = blk_mq_alloc_disk_for_queue(ub->ub_queue,
>  						 &ublk_bio_compl_lkclass);
> -	if (IS_ERR(disk)) {
> -		err = PTR_ERR(disk);
> +	if (!disk) {
> +		err = -ENOMEM;
>  		goto out_free_request_queue;
>  	}

Reviewed-by: Ming Lei <ming.lei@redhat.com>


Thanks,
Ming
Jens Axboe July 18, 2022, 7:13 p.m. UTC | #2
On Mon, 18 Jul 2022 14:14:09 +0300, Dan Carpenter wrote:
> The blk_mq_alloc_disk_for_queue() doesn't return error pointers, it
> returns NULL on error.
> 
> 

Applied, thanks!

[1/3] ublk_drv: fix an IS_ERR() vs NULL check
      commit: fe3333f6953848f1c24e91a1cf70eed026dc3a86

Best regards,
diff mbox series

Patch

diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
index 52fd0af8a4f2..97725d13e4bd 100644
--- a/drivers/block/ublk_drv.c
+++ b/drivers/block/ublk_drv.c
@@ -1175,8 +1175,8 @@  static int ublk_add_dev(struct ublk_device *ub)
 
 	disk = ub->ub_disk = blk_mq_alloc_disk_for_queue(ub->ub_queue,
 						 &ublk_bio_compl_lkclass);
-	if (IS_ERR(disk)) {
-		err = PTR_ERR(disk);
+	if (!disk) {
+		err = -ENOMEM;
 		goto out_free_request_queue;
 	}