LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
From: Luis Chamberlain <mcgrof@kernel.org>
To: axboe@kernel.dk, martin.petersen@oracle.com, jejb@linux.ibm.com,
	kbusch@kernel.org, sagi@grimberg.me, adrian.hunter@intel.com,
	beanhuo@micron.com, ulf.hansson@linaro.org, avri.altman@wdc.com,
	swboyd@chromium.org, agk@redhat.com, snitzer@redhat.com,
	josef@toxicpanda.com
Cc: hch@infradead.org, hare@suse.de, bvanassche@acm.org,
	ming.lei@redhat.com, linux-scsi@vger.kernel.org,
	linux-nvme@lists.infradead.org, linux-mmc@vger.kernel.org,
	dm-devel@redhat.com, nbd@other.debian.org,
	linux-block@vger.kernel.org, linux-kernel@vger.kernel.org,
	Luis Chamberlain <mcgrof@kernel.org>,
	Christoph Hellwig <hch@lst.de>, Song Liu <songliubraving@fb.com>
Subject: [PATCH v4 3/6] md: add error handling support for add_disk()
Date: Mon, 27 Sep 2021 14:59:55 -0700	[thread overview]
Message-ID: <20210927215958.1062466-4-mcgrof@kernel.org> (raw)
In-Reply-To: <20210927215958.1062466-1-mcgrof@kernel.org>

We never checked for errors on add_disk() as this function
returned void. Now that this is fixed, use the shiny new
error handling.

We just do the unwinding of what was not done before, and are
sure to unlock prior to bailing.

Reviewed-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
Signed-off-by: Song Liu <songliubraving@fb.com>
---
 drivers/md/md.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/md/md.c b/drivers/md/md.c
index 6c0c3d0d905a..6bd5ad3c30b4 100644
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -5700,7 +5700,11 @@ static int md_alloc(dev_t dev, char *name)
 	disk->flags |= GENHD_FL_EXT_DEVT;
 	disk->events |= DISK_EVENT_MEDIA_CHANGE;
 	mddev->gendisk = disk;
-	add_disk(disk);
+	error = add_disk(disk);
+	if (error) {
+		blk_cleanup_disk(disk);
+		goto abort;
+	}
 
 	error = kobject_add(&mddev->kobj, &disk_to_dev(disk)->kobj, "%s", "md");
 	if (error) {
-- 
2.30.2


  parent reply	other threads:[~2021-09-27 22:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-27 21:59 [PATCH v4 0/6] block: first batch of add_disk() error handling conversions Luis Chamberlain
2021-09-27 21:59 ` [PATCH v4 1/6] scsi/sd: add error handling support for add_disk() Luis Chamberlain
2021-09-27 21:59 ` [PATCH v4 2/6] scsi/sr: " Luis Chamberlain
2021-09-27 21:59 ` Luis Chamberlain [this message]
2021-09-27 21:59 ` [PATCH v4 4/6] dm: add add_disk() error handling Luis Chamberlain
2021-10-06 13:17   ` Mike Snitzer
2021-09-27 21:59 ` [PATCH v4 5/6] loop: add error handling support for add_disk() Luis Chamberlain
2021-09-27 22:28   ` Jens Axboe
2021-09-27 21:59 ` [PATCH v4 6/6] nbd: " Luis Chamberlain
2021-09-27 22:28   ` 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=20210927215958.1062466-4-mcgrof@kernel.org \
    --to=mcgrof@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=agk@redhat.com \
    --cc=avri.altman@wdc.com \
    --cc=axboe@kernel.dk \
    --cc=beanhuo@micron.com \
    --cc=bvanassche@acm.org \
    --cc=dm-devel@redhat.com \
    --cc=hare@suse.de \
    --cc=hch@infradead.org \
    --cc=hch@lst.de \
    --cc=jejb@linux.ibm.com \
    --cc=josef@toxicpanda.com \
    --cc=kbusch@kernel.org \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=ming.lei@redhat.com \
    --cc=nbd@other.debian.org \
    --cc=sagi@grimberg.me \
    --cc=snitzer@redhat.com \
    --cc=songliubraving@fb.com \
    --cc=swboyd@chromium.org \
    --cc=ulf.hansson@linaro.org \
    --subject='Re: [PATCH v4 3/6] md: add error handling support for add_disk()' \
    /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

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).