* [PATCH] block: fix checking return value of blk_mq_init_queue
@ 2015-01-02 14:25 Ming Lei
2015-01-02 15:53 ` Jens Axboe
0 siblings, 1 reply; 4+ messages in thread
From: Ming Lei @ 2015-01-02 14:25 UTC (permalink / raw)
To: Jens Axboe, linux-kernel; +Cc: Ming Lei
Check IS_ERR_OR_NULL(return value) instead of just return value.
Signed-off-by: Ming Lei <ming.lei@canonical.com>
---
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(-)
diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c
index ae9f615..f73fc5a 100644
--- a/drivers/block/null_blk.c
+++ b/drivers/block/null_blk.c
@@ -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;
}
diff --git a/drivers/block/nvme-core.c b/drivers/block/nvme-core.c
index b1d5d87..0d2fbe6 100644
--- a/drivers/block/nvme-core.c
+++ b/drivers/block/nvme-core.c
@@ -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;
}
diff --git a/drivers/block/virtio_blk.c b/drivers/block/virtio_blk.c
index 7ef7c09..d594db0 100644
--- a/drivers/block/virtio_blk.c
+++ b/drivers/block/virtio_blk.c
@@ -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;
}
--
1.7.9.5
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] block: fix checking return value of blk_mq_init_queue
2015-01-02 14:25 [PATCH] block: fix checking return value of blk_mq_init_queue Ming Lei
@ 2015-01-02 15:53 ` Jens Axboe
2015-01-02 17:34 ` Al Viro
0 siblings, 1 reply; 4+ messages in thread
From: Jens Axboe @ 2015-01-02 15:53 UTC (permalink / raw)
To: Ming Lei, linux-kernel
On 01/02/2015 07:25 AM, Ming Lei wrote:
> Check IS_ERR_OR_NULL(return value) instead of just return value.
Thanks Ming, applied.
--
Jens Axboe
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] block: fix checking return value of blk_mq_init_queue
2015-01-02 15:53 ` Jens Axboe
@ 2015-01-02 17:34 ` Al Viro
2015-01-02 17:40 ` Jens Axboe
0 siblings, 1 reply; 4+ messages in thread
From: Al Viro @ 2015-01-02 17:34 UTC (permalink / raw)
To: Jens Axboe; +Cc: Ming Lei, linux-kernel
On Fri, Jan 02, 2015 at 08:53:11AM -0700, Jens Axboe wrote:
> On 01/02/2015 07:25 AM, Ming Lei wrote:
> >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...
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] block: fix checking return value of blk_mq_init_queue
2015-01-02 17:34 ` Al Viro
@ 2015-01-02 17:40 ` Jens Axboe
0 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2015-01-02 17:40 UTC (permalink / raw)
To: Al Viro; +Cc: Ming Lei, linux-kernel
On 01/02/2015 10:34 AM, Al Viro wrote:
> On Fri, Jan 02, 2015 at 08:53:11AM -0700, Jens Axboe wrote:
>> On 01/02/2015 07:25 AM, Ming Lei wrote:
>>> 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...
I actually made that change when committing it:
http://git.kernel.dk/?p=linux-block.git;a=commit;h=35b489d32fcc37e8735f41aa794b24cf9d1e74f5
--
Jens Axboe
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2015-01-02 17:40 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-02 14:25 [PATCH] block: fix checking return value of blk_mq_init_queue Ming Lei
2015-01-02 15:53 ` Jens Axboe
2015-01-02 17:34 ` Al Viro
2015-01-02 17:40 ` Jens Axboe
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox