[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211103181258.1462704-3-mcgrof@kernel.org>
Date: Wed, 3 Nov 2021 11:12:56 -0700
From: Luis Chamberlain <mcgrof@...nel.org>
To: axboe@...nel.dk, hch@....de, penguin-kernel@...ove.sakura.ne.jp,
dan.j.williams@...el.com, vishal.l.verma@...el.com,
dave.jiang@...el.com, ira.weiny@...el.com, richard@....at,
miquel.raynal@...tlin.com, vigneshr@...com, efremov@...ux.com,
song@...nel.org, martin.petersen@...cle.com, hare@...e.de,
jack@...e.cz, ming.lei@...hat.com, tj@...nel.org, mcgrof@...nel.org
Cc: linux-mtd@...ts.infradead.org, linux-scsi@...r.kernel.org,
linux-raid@...r.kernel.org, linux-block@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH v4 2/4] ataflop: address add_disk() error handling on probe
We need to cleanup resources on the probe() callback registered
with __register_blkdev(), now that add_disk() error handling is
supported. Address this.
Signed-off-by: Luis Chamberlain <mcgrof@...nel.org>
---
drivers/block/ataflop.c | 16 +++++++++++++---
1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/drivers/block/ataflop.c b/drivers/block/ataflop.c
index 170dd193cef6..e981b351f37e 100644
--- a/drivers/block/ataflop.c
+++ b/drivers/block/ataflop.c
@@ -2012,6 +2012,7 @@ static void ataflop_probe(dev_t dev)
{
int drive = MINOR(dev) & 3;
int type = MINOR(dev) >> 2;
+ int err = 0;
if (type)
type--;
@@ -2019,11 +2020,20 @@ static void ataflop_probe(dev_t dev)
if (drive >= FD_MAX_UNITS || type >= NUM_DISK_MINORS)
return;
if (!unit[drive].disk[type]) {
- if (ataflop_alloc_disk(drive, type) == 0) {
- add_disk(unit[drive].disk[type]);
- unit[drive].registered[type] = true;
+ err = ataflop_alloc_disk(drive, type);
+ if (err == 0) {
+ err = add_disk(unit[drive].disk[type]);
+ if (err)
+ goto err_out;
+ else
+ unit[drive].registered[type] = true;
}
}
+ return;
+
+err_out:
+ blk_cleanup_disk(unit[drive].disk[type]);
+ unit[drive].disk[type] = NULL;
}
static void atari_floppy_cleanup(void)
--
2.33.0
Powered by blists - more mailing lists