From: Pan Bian <bianpan2016@163.com>
To: Markus Pargmann <mpa@pengutronix.de>, nbd-general@lists.sourceforge.net
Cc: linux-kernel@vger.kernel.org, Pan Bian <bianpan2016@163.com>
Subject: [PATCH 1/1] block: nbd: fix bugs in nbd_init
Date: Thu, 1 Dec 2016 10:51:38 +0800 [thread overview]
Message-ID: <1480560698-2260-1-git-send-email-bianpan2016@163.com> (raw)
Fix bug https://bugzilla.kernel.org/show_bug.cgi?id=188441. Fix 3 bugs
in function nbd_init: (1) set error code (-ENOMEM) when the call to
alloc_disk() fails; (2) function blk_mq_init_queue() returns an
ERR_PTR pointer rather than NULL on failures, so use IS_ERR to check the
return value; (3) set error code on the branch that blk_mq_init_queue()
returns an invalid pointer.
Signed-off-by: Pan Bian <bianpan2016@163.com>
---
drivers/block/nbd.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
index 7a10487..200e899 100644
--- a/drivers/block/nbd.c
+++ b/drivers/block/nbd.c
@@ -930,8 +930,10 @@ static int __init nbd_init(void)
for (i = 0; i < nbds_max; i++) {
struct gendisk *disk = alloc_disk(1 << part_shift);
- if (!disk)
+ if (!disk) {
+ err = -ENOMEM;
goto out;
+ }
nbd_dev[i].disk = disk;
nbd_dev[i].tag_set.ops = &nbd_mq_ops;
@@ -955,7 +957,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;
--
1.9.1
reply other threads:[~2016-12-01 2:52 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=1480560698-2260-1-git-send-email-bianpan2016@163.com \
--to=bianpan2016@163.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mpa@pengutronix.de \
--cc=nbd-general@lists.sourceforge.net \
/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®