diff mbox series

block: loop: check error using IS_ERR instead of IS_ERR_OR_NULL in loop_add()

Message ID 20181216093500.25023-1-cgxu519@gmx.com (mailing list archive)
State New, archived
Headers show
Series block: loop: check error using IS_ERR instead of IS_ERR_OR_NULL in loop_add() | expand

Commit Message

Chengguang Xu Dec. 16, 2018, 9:35 a.m. UTC
blk_mq_init_queue() will not return NULL pointer to its caller,
so it's better to replace IS_ERR_OR_NULL using IS_ERR in loop_add().

If in the future things change to check NULL pointer inside loop_add(),
we should return -ENOMEM as return code instead of PTR_ERR(NULL).

Signed-off-by: Chengguang Xu <cgxu519@gmx.com>
---
 drivers/block/loop.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Jens Axboe Dec. 16, 2018, 3:47 p.m. UTC | #1
On 12/16/18 2:35 AM, Chengguang Xu wrote:
> blk_mq_init_queue() will not return NULL pointer to its caller,
> so it's better to replace IS_ERR_OR_NULL using IS_ERR in loop_add().
> 
> If in the future things change to check NULL pointer inside loop_add(),
> we should return -ENOMEM as return code instead of PTR_ERR(NULL).

That won't change, I really dislike functions that return NULL if
they also return an ERR_PTR.

Applied, thanks.
diff mbox series

Patch

diff --git a/drivers/block/loop.c b/drivers/block/loop.c
index cb0cc8685076..849a48120cca 100644
--- a/drivers/block/loop.c
+++ b/drivers/block/loop.c
@@ -1853,7 +1853,7 @@  static int loop_add(struct loop_device **l, int i)
 		goto out_free_idr;
 
 	lo->lo_queue = blk_mq_init_queue(&lo->tag_set);
-	if (IS_ERR_OR_NULL(lo->lo_queue)) {
+	if (IS_ERR(lo->lo_queue)) {
 		err = PTR_ERR(lo->lo_queue);
 		goto out_cleanup_tags;
 	}