block: fix checking return value of blk_mq_init_queue
Subsystems (3)
PATCH 1/1 block: fix checking return value of blk_mq_init_queue
Check IS_ERR_OR_NULL(return value) instead of just return value.
--- drivers/block/null_blk.c | 2 +- drivers/block/nvme-core.c | 2 +- drivers/block/virtio_blk.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/block/null_blk.c +1 -1
@@ -530,7 +530,7 @@ static int null_add_dev(void) goto out_cleanup_queues; nullb->q =blk_mq_init_queue (&nullb->tag_set); -if (!nullb->q) { +if (IS_ERR_OR_NULL (nullb->q)) { rv = -ENOMEM ; goto out_cleanup_tags; }
drivers/block/nvme-core.c +1 -1
@@ -1370,7 +1370,7 @@ static int nvme_alloc_admin_tags(struct nvme_dev *dev)return -ENOMEM ; dev->admin_q =blk_mq_init_queue (&dev->admin_tagset); -if (!dev->admin_q) { +if (IS_ERR_OR_NULL (dev->admin_q)) {blk_mq_free_tag_set (&dev->admin_tagset);return -ENOMEM ; }
drivers/block/virtio_blk.c +1 -1
@@ -638,7 +638,7 @@ static int virtblk_probe(struct virtio_device *vdev) goto out_put_disk; q = vblk->disk->queue =blk_mq_init_queue (&vblk->tag_set); -if (!q) { +if (IS_ERR_OR_NULL (q)) { err = -ENOMEM ; goto out_free_tags; }
Signature · 1 line
1.7.9.5
Quoted 1 line · Ming Lei
Check
IS_ERR_OR_NULL(return value)instead of just return value.
Thanks Ming, applied.
Signature · 1 line
Jens Axboe
Quoted 4 lines · Jens Axboe
Quoted 1 line · Ming Lei
Check
IS_ERR_OR_NULL(return value)instead of just return value.Thanks Ming, applied.
Umm... Looking at the callers, I'd suggest making it _never_ return NULL - it's always treates as ERR_PTR(-ENOMEM) anyway. Then the checks would be just IS_ERR(...).
IS_ERR_OR_NULL() is very often a sign of lousy calling conventions and this case is no exception...
Quoted 4 lines · Al Viro
Quoted 3 lines · Jens Axboe
Quoted 1 line · Ming Lei
Check
IS_ERR_OR_NULL(return value)instead of just return value.
Quoted 8 lines
Quoted 1 line
Thanks Ming, applied.
Umm... Looking at the callers, I'd suggest making it _never_ return NULL - it's always treates as
ERR_PTR(-ENOMEM)anyway. Then the checks would be justIS_ERR(...).
IS_ERR_OR_NULL()is very often a sign of lousy calling conventions and this case is no exception...
I actually made that change when committing it:
http://git.kernel.dk/?p=linux-block.git;a=commit;h=35b489d32fcc37e8735f41aa794b24cf9d1e74f5
Signature · 1 line
Jens Axboe