[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20211103230437.1639990-14-mcgrof@kernel.org>
Date: Wed, 3 Nov 2021 16:04:36 -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 v5 13/14] floppy: 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.
Reviewed-by: Christoph Hellwig <hch@....de>
Signed-off-by: Luis Chamberlain <mcgrof@...nel.org>
---
drivers/block/floppy.c | 17 +++++++++++++----
1 file changed, 13 insertions(+), 4 deletions(-)
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index 3873e789478e..c4267da716fe 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -4528,10 +4528,19 @@ static void floppy_probe(dev_t dev)
return;
mutex_lock(&floppy_probe_lock);
- if (!disks[drive][type]) {
- if (floppy_alloc_disk(drive, type) == 0)
- add_disk(disks[drive][type]);
- }
+ if (disks[drive][type])
+ goto out;
+ if (floppy_alloc_disk(drive, type))
+ goto out;
+ if (add_disk(disks[drive][type]))
+ goto cleanup_disk;
+out:
+ mutex_unlock(&floppy_probe_lock);
+ return;
+
+cleanup_disk:
+ blk_cleanup_disk(disks[drive][type]);
+ disks[drive][type] = NULL;
mutex_unlock(&floppy_probe_lock);
}
--
2.33.0
Powered by blists - more mailing lists