summaryrefslogtreecommitdiff
path: root/drivers/block
diff options
context:
space:
mode:
authorLuis Chamberlain <mcgrof@kernel.org>2021-11-04 02:04:35 +0300
committerJens Axboe <axboe@kernel.dk>2021-11-04 14:48:50 +0300
commit46a7db492e7a27408bc164cbe6424683e79529b0 (patch)
treeca67ec5b4ce720f085e2f7dd27b8437cce613958 /drivers/block
parent26e06f5b13671d194d67ae8e2b66f524ab174153 (diff)
downloadlinux-46a7db492e7a27408bc164cbe6424683e79529b0.tar.xz
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. Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Luis Chamberlain <mcgrof@kernel.org> Link: https://lore.kernel.org/r/20211103230437.1639990-13-mcgrof@kernel.org Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/ataflop.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/drivers/block/ataflop.c b/drivers/block/ataflop.c
index 170dd193cef6..de8c3785899a 100644
--- a/drivers/block/ataflop.c
+++ b/drivers/block/ataflop.c
@@ -2018,12 +2018,18 @@ 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;
- }
- }
+ if (unit[drive].disk[type])
+ return
+ if (ataflop_alloc_disk(drive, type))
+ return;
+ if (add_disk(unit[drive].disk[type]))
+ goto cleanup_disk;
+ unit[drive].registered[type] = true;
+ return;
+
+cleanup_disk:
+ blk_cleanup_disk(unit[drive].disk[type]);
+ unit[drive].disk[type] = NULL;
}
static void atari_floppy_cleanup(void)