mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Wei Yongjun <weiyj.lk@gmail.com>
To: Markus Pargmann <mpa@pengutronix.de>, Josef Bacik <jbacik@fb.com>
Cc: Wei Yongjun <weiyongjun1@huawei.com>,
	nbd-general@lists.sourceforge.net, linux-kernel@vger.kernel.org
Subject: [PATCH -next] nbd: fix return value check
Date: Thu, 15 Sep 2016 03:26:23 +0000	[thread overview]
Message-ID: <1473909983-30866-1-git-send-email-weiyj.lk@gmail.com> (raw)

From: Wei Yongjun <weiyongjun1@huawei.com>

In case of error, the function blk_mq_alloc_request() or
blk_mq_init_queue() returns ERR_PTR() not  NULL. The NULL
test in the return value check should be replaced with
IS_ERR().

Fixes: fd8383fd88a2 ("nbd: convert to blkmq")
Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
---
 drivers/block/nbd.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 4c6dd1a..62ff9cb 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -599,8 +599,8 @@ 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)
-			return -ENOMEM;
+		if (IS_ERR(sreq))
+			return PTR_ERR(sreq);
 
 		mutex_unlock(&nbd->tx_lock);
 		fsync_bdev(bdev);
@@ -956,7 +956,8 @@ static int __init nbd_init(void)
 		 * These structs are big so we dynamically allocate them.
 		 */
 		disk->queue = blk_mq_init_queue(&nbd_dev[i].tag_set);
-		if (!disk->queue) {
+		if (IS_ERR(disk->queue)) {
+			err = PTR_ERR(disk->queue);
 			blk_mq_free_tag_set(&nbd_dev[i].tag_set);
 			put_disk(disk);
 			goto out;

                 reply	other threads:[~2016-09-15  3:27 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1473909983-30866-1-git-send-email-weiyj.lk@gmail.com \
    --to=weiyj.lk@gmail.com \
    --cc=jbacik@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mpa@pengutronix.de \
    --cc=nbd-general@lists.sourceforge.net \
    --cc=weiyongjun1@huawei.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®