linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Omar Sandoval <osandov@osandov.com>
To: Jeff Moyer <jmoyer@redhat.com>
Cc: axboe@kernel.dk, Markus Pargmann <mpa@pengutronix.de>,
	linux-block@vger.kernel.org, nbd-general@lists.sourceforge.net,
	linux-kernel@vger.kernel.org, Josef Bacik <jbacik@fb.com>
Subject: Re: [patch] nbd: blk_mq_init_queue returns an error code on failure, not NULL
Date: Mon, 9 Jan 2017 12:27:07 -0800	[thread overview]
Message-ID: <20170109202707.GA29762@vader.DHCP.thefacebook.com> (raw)
In-Reply-To: <x49vatogf3k.fsf@segfault.boston.devel.redhat.com>

On Mon, Jan 09, 2017 at 03:20:31PM -0500, Jeff Moyer wrote:
> Additionally, don't assign directly to disk->queue, otherwise
> blk_put_queue (called via put_disk) will choke (panic) on the errno
> stored there.
> 
> Bug found by code inspection after Omar found a similar issue in
> virtio_blk.  Compile-tested only.
> 
> Signed-off-by: Jeff Moyer <jmoyer@redhat.com>

Reviewed-by: Omar Sandoval <osandov@fb.com>

Compile-reviewed only :) Josef can probably test it if he cares enough,
but it looks right.

> diff --git a/drivers/block/nbd.c b/drivers/block/nbd.c
> index 38c576f..50a2020 100644
> --- a/drivers/block/nbd.c
> +++ b/drivers/block/nbd.c
> @@ -1042,6 +1042,7 @@ static int __init nbd_init(void)
>  		return -ENOMEM;
>  
>  	for (i = 0; i < nbds_max; i++) {
> +		struct request_queue *q;
>  		struct gendisk *disk = alloc_disk(1 << part_shift);
>  		if (!disk)
>  			goto out;
> @@ -1067,12 +1068,13 @@ static int __init nbd_init(void)
>  		 * every gendisk to have its very own request_queue struct.
>  		 * These structs are big so we dynamically allocate them.
>  		 */
> -		disk->queue = blk_mq_init_queue(&nbd_dev[i].tag_set);
> -		if (!disk->queue) {
> +		q = blk_mq_init_queue(&nbd_dev[i].tag_set);
> +		if (IS_ERR(q)) {
>  			blk_mq_free_tag_set(&nbd_dev[i].tag_set);
>  			put_disk(disk);
>  			goto out;
>  		}
> +		disk->queue = q;
>  
>  		/*
>  		 * Tell the block layer that we are not a rotational device

  reply	other threads:[~2017-01-09 20:27 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-09 20:20 [patch] nbd: blk_mq_init_queue returns an error code on failure, not NULL Jeff Moyer
2017-01-09 20:27 ` Omar Sandoval [this message]
2017-01-09 20:41   ` Jens Axboe
2017-01-09 20:44     ` Josef Bacik

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=20170109202707.GA29762@vader.DHCP.thefacebook.com \
    --to=osandov@osandov.com \
    --cc=axboe@kernel.dk \
    --cc=jbacik@fb.com \
    --cc=jmoyer@redhat.com \
    --cc=linux-block@vger.kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).