Skip to contentSkip to conversation

ublk_drv: fix an IS_ERR() vs NULL check

PATCH Applied Dan Carpenter 3 participants 3 messages Jul 18, 2022

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

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

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")
---
 drivers/block/ublk_drv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/block/ublk_drv.c +2 -2
index 52fd0af8a4f2..97725d13e4bd 100644
@@ -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;
 	}
 
Signature · 1 line
2.35.1
Reviewed-by on v1 1/3
#1 lore raw
Quoted 14 lines · Dan Carpenter

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")
---
 drivers/block/ublk_drv.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/block/ublk_drv.c +0 -0
index 52fd0af8a4f2..97725d13e4bd 100644

drivers/block/ublk_drv.c static int ublk_add_dev(struct ublk_device *ub) · line 1181

Quoted 9 lines
drivers/block/ublk_drv.c +2 -2
@@ -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;
 	}

Thanks,
Ming

maintainer Applied
#2 lore raw
In reply to Dan Carpenter
Quoted 4 lines · Dan Carpenter

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,

Signature · 1 line
Jens Axboe