From: Luis Chamberlain <mcgrof@kernel.org>
To: axboe@kernel.dk, jejb@linux.ibm.com, martin.petersen@oracle.com,
agk@redhat.com, snitzer@redhat.com, colyli@suse.de,
kent.overstreet@gmail.com, boris.ostrovsky@oracle.com,
jgross@suse.com, sstabellini@kernel.org, roger.pau@citrix.com,
geert@linux-m68k.org, ulf.hansson@linaro.org, tj@kernel.org,
hare@suse.de, jdike@addtoit.com, richard@nod.at,
anton.ivanov@cambridgegreys.com, johannes.berg@intel.com,
krisman@collabora.com, chris.obbard@collabora.com,
thehajime@gmail.com, zhuyifei1999@gmail.com,
haris.iqbal@ionos.com, jinpu.wang@ionos.com,
miquel.raynal@bootlin.com, vigneshr@ti.com,
linux-mtd@lists.infradead.org
Cc: linux-scsi@vger.kernel.org, dm-devel@redhat.com,
linux-bcache@vger.kernel.org, xen-devel@lists.xenproject.org,
linux-m68k@lists.linux-m68k.org, linux-um@lists.infradead.org,
linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
Luis Chamberlain <mcgrof@kernel.org>
Subject: [PATCH 5/9] xen-blkfront: add error handling support for add_disk()
Date: Fri, 15 Oct 2021 16:30:24 -0700 [thread overview]
Message-ID: <20211015233028.2167651-6-mcgrof@kernel.org> (raw)
In-Reply-To: <20211015233028.2167651-1-mcgrof@kernel.org>
We never checked for errors on device_add_disk() as this function
returned void. Now that this is fixed, use the shiny new error
handling. The function xlvbd_alloc_gendisk() typically does the
unwinding on error on allocating the disk and creating the tag,
but since all that error handling was stuffed inside
xlvbd_alloc_gendisk() we must repeat the tag free'ing as well.
We set the info->rq to NULL to ensure blkif_free() doesn't crash
on blk_mq_stop_hw_queues() on device_add_disk() error as the queue
will be long gone by then.
Reviewed-by: Juergen Gross <jgross@suse.com>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
drivers/block/xen-blkfront.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c
index df0deb927760..8e3983e456f3 100644
--- a/drivers/block/xen-blkfront.c
+++ b/drivers/block/xen-blkfront.c
@@ -2386,7 +2386,13 @@ static void blkfront_connect(struct blkfront_info *info)
for_each_rinfo(info, rinfo, i)
kick_pending_request_queues(rinfo);
- device_add_disk(&info->xbdev->dev, info->gd, NULL);
+ err = device_add_disk(&info->xbdev->dev, info->gd, NULL);
+ if (err) {
+ blk_cleanup_disk(info->gd);
+ blk_mq_free_tag_set(&info->tag_set);
+ info->rq = NULL;
+ goto fail;
+ }
info->is_ready = 1;
return;
--
2.30.2
next prev parent reply other threads:[~2021-10-15 23:31 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-15 23:30 [PATCH 0/9] block: reviewed add_disk() error handling set Luis Chamberlain
2021-10-15 23:30 ` [PATCH 1/9] scsi/sd: add error handling support for add_disk() Luis Chamberlain
2021-10-17 2:51 ` Martin K. Petersen
2021-10-18 20:31 ` Luis Chamberlain
2021-10-19 2:52 ` Martin K. Petersen
2021-10-15 23:30 ` [PATCH 2/9] scsi/sr: " Luis Chamberlain
2021-10-17 2:53 ` Martin K. Petersen
2021-10-15 23:30 ` [PATCH 3/9] dm: add add_disk() error handling Luis Chamberlain
2021-10-15 23:30 ` [PATCH 4/9] bcache: add error handling support for add_disk() Luis Chamberlain
2021-10-15 23:30 ` Luis Chamberlain [this message]
2021-10-15 23:30 ` [PATCH 6/9] m68k/emu/nfblock: " Luis Chamberlain
2021-10-15 23:30 ` [PATCH 7/9] um/drivers/ubd_kern: " Luis Chamberlain
2021-10-15 23:30 ` [PATCH 8/9] rnbd: " Luis Chamberlain
2021-10-15 23:30 ` [PATCH 9/9] mtd: add add_disk() error handling Luis Chamberlain
2021-10-21 3:42 ` [PATCH 0/9] block: reviewed add_disk() error handling set Martin K. Petersen
2021-10-21 15:01 ` (subset) " Jens Axboe
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=20211015233028.2167651-6-mcgrof@kernel.org \
--to=mcgrof@kernel.org \
--cc=agk@redhat.com \
--cc=anton.ivanov@cambridgegreys.com \
--cc=axboe@kernel.dk \
--cc=boris.ostrovsky@oracle.com \
--cc=chris.obbard@collabora.com \
--cc=colyli@suse.de \
--cc=dm-devel@redhat.com \
--cc=geert@linux-m68k.org \
--cc=hare@suse.de \
--cc=haris.iqbal@ionos.com \
--cc=jdike@addtoit.com \
--cc=jejb@linux.ibm.com \
--cc=jgross@suse.com \
--cc=jinpu.wang@ionos.com \
--cc=johannes.berg@intel.com \
--cc=kent.overstreet@gmail.com \
--cc=krisman@collabora.com \
--cc=linux-bcache@vger.kernel.org \
--cc=linux-block@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-m68k@lists.linux-m68k.org \
--cc=linux-mtd@lists.infradead.org \
--cc=linux-scsi@vger.kernel.org \
--cc=linux-um@lists.infradead.org \
--cc=martin.petersen@oracle.com \
--cc=miquel.raynal@bootlin.com \
--cc=richard@nod.at \
--cc=roger.pau@citrix.com \
--cc=snitzer@redhat.com \
--cc=sstabellini@kernel.org \
--cc=thehajime@gmail.com \
--cc=tj@kernel.org \
--cc=ulf.hansson@linaro.org \
--cc=vigneshr@ti.com \
--cc=xen-devel@lists.xenproject.org \
--cc=zhuyifei1999@gmail.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;
as well as URLs for NNTP newsgroup(s).