All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luis Chamberlain <mcgrof@kernel.org>
To: axboe@kernel.dk, hch@lst.de, penguin-kernel@i-love.sakura.ne.jp,
	dan.j.williams@intel.com, vishal.l.verma@intel.com,
	dave.jiang@intel.com, ira.weiny@intel.com, richard@nod.at,
	miquel.raynal@bootlin.com, vigneshr@ti.com, efremov@linux.com,
	song@kernel.org, martin.petersen@oracle.com, hare@suse.de,
	jack@suse.cz, ming.lei@redhat.com, tj@kernel.org,
	mcgrof@kernel.org
Cc: linux-mtd@lists.infradead.org, linux-scsi@vger.kernel.org,
	linux-raid@vger.kernel.org, linux-block@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH v2 10/13] mtd/ubi/block: add error handling support for add_disk()
Date: Wed,  3 Nov 2021 05:21:54 -0700	[thread overview]
Message-ID: <20211103122157.1215783-11-mcgrof@kernel.org> (raw)
In-Reply-To: <20211103122157.1215783-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.

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 drivers/mtd/ubi/block.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/ubi/block.c b/drivers/mtd/ubi/block.c
index e003b4b44ffa..062e6c2c45f5 100644
--- a/drivers/mtd/ubi/block.c
+++ b/drivers/mtd/ubi/block.c
@@ -447,12 +447,18 @@ int ubiblock_create(struct ubi_volume_info *vi)
 	list_add_tail(&dev->list, &ubiblock_devices);
 
 	/* Must be the last step: anyone can call file ops from now on */
-	add_disk(dev->gd);
+	ret = add_disk(dev->gd);
+	if (ret)
+		goto out_destroy_wq;
+
 	dev_info(disk_to_dev(dev->gd), "created from ubi%d:%d(%s)",
 		 dev->ubi_num, dev->vol_id, vi->name);
 	mutex_unlock(&devices_mutex);
 	return 0;
 
+out_destroy_wq:
+	list_del(&dev->list);
+	destroy_workqueue(dev->wq);
 out_remove_minor:
 	idr_remove(&ubiblock_minor_idr, gd->first_minor);
 out_cleanup_disk:
-- 
2.33.0


WARNING: multiple messages have this Message-ID (diff)
From: Luis Chamberlain <mcgrof@kernel.org>
To: axboe@kernel.dk, hch@lst.de, penguin-kernel@i-love.sakura.ne.jp,
	dan.j.williams@intel.com, vishal.l.verma@intel.com,
	dave.jiang@intel.com, ira.weiny@intel.com, richard@nod.at,
	miquel.raynal@bootlin.com, vigneshr@ti.com, efremov@linux.com,
	song@kernel.org, martin.petersen@oracle.com, hare@suse.de,
	jack@suse.cz, ming.lei@redhat.com, tj@kernel.org,
	mcgrof@kernel.org
Cc: linux-mtd@lists.infradead.org, linux-scsi@vger.kernel.org,
	linux-raid@vger.kernel.org, linux-block@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH v2 10/13] mtd/ubi/block: add error handling support for add_disk()
Date: Wed,  3 Nov 2021 05:21:54 -0700	[thread overview]
Message-ID: <20211103122157.1215783-11-mcgrof@kernel.org> (raw)
In-Reply-To: <20211103122157.1215783-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.

Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
---
 drivers/mtd/ubi/block.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/mtd/ubi/block.c b/drivers/mtd/ubi/block.c
index e003b4b44ffa..062e6c2c45f5 100644
--- a/drivers/mtd/ubi/block.c
+++ b/drivers/mtd/ubi/block.c
@@ -447,12 +447,18 @@ int ubiblock_create(struct ubi_volume_info *vi)
 	list_add_tail(&dev->list, &ubiblock_devices);
 
 	/* Must be the last step: anyone can call file ops from now on */
-	add_disk(dev->gd);
+	ret = add_disk(dev->gd);
+	if (ret)
+		goto out_destroy_wq;
+
 	dev_info(disk_to_dev(dev->gd), "created from ubi%d:%d(%s)",
 		 dev->ubi_num, dev->vol_id, vi->name);
 	mutex_unlock(&devices_mutex);
 	return 0;
 
+out_destroy_wq:
+	list_del(&dev->list);
+	destroy_workqueue(dev->wq);
 out_remove_minor:
 	idr_remove(&ubiblock_minor_idr, gd->first_minor);
 out_cleanup_disk:
-- 
2.33.0


______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/

  parent reply	other threads:[~2021-11-03 12:22 UTC|newest]

Thread overview: 62+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-03 12:21 [PATCH v2 00/13] block: add_disk() error handling stragglers Luis Chamberlain
2021-11-03 12:21 ` Luis Chamberlain
2021-11-03 12:21 ` [PATCH v2 01/13] nvdimm/btt: do not call del_gendisk() if not needed Luis Chamberlain
2021-11-03 12:21   ` Luis Chamberlain
2021-11-03 16:02   ` Christoph Hellwig
2021-11-03 16:02     ` Christoph Hellwig
2021-11-03 16:58     ` Luis Chamberlain
2021-11-03 16:58       ` Luis Chamberlain
2021-11-03 12:21 ` [PATCH v2 02/13] nvdimm/btt: use goto error labels on btt_blk_init() Luis Chamberlain
2021-11-03 12:21   ` Luis Chamberlain
2021-11-03 16:02   ` Christoph Hellwig
2021-11-03 16:02     ` Christoph Hellwig
2021-11-03 12:21 ` [PATCH v2 03/13] nvdimm/btt: add error handling support for add_disk() Luis Chamberlain
2021-11-03 12:21   ` Luis Chamberlain
2021-11-03 16:04   ` Christoph Hellwig
2021-11-03 16:04     ` Christoph Hellwig
2021-11-03 12:21 ` [PATCH v2 04/13] nvdimm/blk: avoid calling del_gendisk() on early failures Luis Chamberlain
2021-11-03 12:21   ` Luis Chamberlain
2021-11-03 16:05   ` Christoph Hellwig
2021-11-03 16:05     ` Christoph Hellwig
2021-11-03 16:47     ` Luis Chamberlain
2021-11-03 16:47       ` Luis Chamberlain
2021-11-03 12:21 ` [PATCH v2 05/13] nvdimm/blk: add error handling support for add_disk() Luis Chamberlain
2021-11-03 12:21   ` Luis Chamberlain
2021-11-03 16:06   ` Christoph Hellwig
2021-11-03 16:06     ` Christoph Hellwig
2021-11-03 12:21 ` [PATCH v2 06/13] nvdimm/pmem: cleanup the disk if pmem_release_disk() is yet assigned Luis Chamberlain
2021-11-03 12:21   ` Luis Chamberlain
2021-11-03 16:06   ` Christoph Hellwig
2021-11-03 16:06     ` Christoph Hellwig
2021-11-03 12:21 ` [PATCH v2 07/13] nvdimm/pmem: use add_disk() error handling Luis Chamberlain
2021-11-03 12:21   ` Luis Chamberlain
2021-11-03 16:06   ` Christoph Hellwig
2021-11-03 16:06     ` Christoph Hellwig
2021-11-03 12:21 ` [PATCH v2 08/13] z2ram: add error handling support for add_disk() Luis Chamberlain
2021-11-03 12:21   ` Luis Chamberlain
2021-11-03 16:07   ` Christoph Hellwig
2021-11-03 16:07     ` Christoph Hellwig
2021-11-03 12:21 ` [PATCH v2 09/13] block/sunvdc: " Luis Chamberlain
2021-11-03 12:21   ` Luis Chamberlain
2021-11-03 16:07   ` Christoph Hellwig
2021-11-03 16:07     ` Christoph Hellwig
2021-11-03 12:21 ` Luis Chamberlain [this message]
2021-11-03 12:21   ` [PATCH v2 10/13] mtd/ubi/block: " Luis Chamberlain
2021-11-03 16:07   ` Christoph Hellwig
2021-11-03 16:07     ` Christoph Hellwig
2021-11-03 12:21 ` [PATCH v2 11/13] ataflop: remove ataflop_probe_lock mutex Luis Chamberlain
2021-11-03 12:21   ` Luis Chamberlain
2021-11-03 12:21 ` [PATCH v2 12/13] block: make __register_blkdev() return an error Luis Chamberlain
2021-11-03 12:21   ` Luis Chamberlain
2021-11-03 16:09   ` Christoph Hellwig
2021-11-03 16:09     ` Christoph Hellwig
2021-11-03 16:44     ` Luis Chamberlain
2021-11-03 16:44       ` Luis Chamberlain
2021-11-03 17:00       ` Christoph Hellwig
2021-11-03 17:00         ` Christoph Hellwig
2021-11-03 17:03         ` Luis Chamberlain
2021-11-03 17:03           ` Luis Chamberlain
2021-11-03 12:21 ` [PATCH v2 13/13] block: add __must_check for *add_disk*() callers Luis Chamberlain
2021-11-03 12:21   ` Luis Chamberlain
2021-11-03 17:41 ` [PATCH v2 00/13] block: add_disk() error handling stragglers Luis Chamberlain
2021-11-03 17:41   ` Luis Chamberlain

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=20211103122157.1215783-11-mcgrof@kernel.org \
    --to=mcgrof@kernel.org \
    --cc=axboe@kernel.dk \
    --cc=dan.j.williams@intel.com \
    --cc=dave.jiang@intel.com \
    --cc=efremov@linux.com \
    --cc=hare@suse.de \
    --cc=hch@lst.de \
    --cc=ira.weiny@intel.com \
    --cc=jack@suse.cz \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mtd@lists.infradead.org \
    --cc=linux-raid@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=ming.lei@redhat.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=penguin-kernel@i-love.sakura.ne.jp \
    --cc=richard@nod.at \
    --cc=song@kernel.org \
    --cc=tj@kernel.org \
    --cc=vigneshr@ti.com \
    --cc=vishal.l.verma@intel.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.