nbd: Fix error handling
authorChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Sun, 30 Oct 2016 04:28:27 +0000 (05:28 +0100)
committerJens Axboe <axboe@fb.com>
Sun, 6 Nov 2016 21:14:59 +0000 (14:14 -0700)
'blk_mq_alloc_request()' returns an error pointer in case of error, not
NULL. So test it with IS_ERR.

Fixes: fd8383fd88a2 ("nbd: convert to blkmq")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
Signed-off-by: Jens Axboe <axboe@fb.com>
drivers/block/nbd.c

index 19a16b2dbb917afea67225290ee2d8da654db41d..7a104875591400a896ab3025e5feb4e37ec3e86a 100644 (file)
@@ -599,7 +599,7 @@ static int __nbd_ioctl(struct block_device *bdev, struct nbd_device *nbd,
                        return -EINVAL;
 
                sreq = blk_mq_alloc_request(bdev_get_queue(bdev), WRITE, 0);
-               if (!sreq)
+               if (IS_ERR(sreq))
                        return -ENOMEM;
 
                mutex_unlock(&nbd->tx_lock);