Skip to content

Commit 46a7db4

Browse files
mcgrofaxboe
authored andcommitted
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 <[email protected]> Signed-off-by: Luis Chamberlain <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent 26e06f5 commit 46a7db4

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

drivers/block/ataflop.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2018,12 +2018,18 @@ static void ataflop_probe(dev_t dev)
20182018

20192019
if (drive >= FD_MAX_UNITS || type >= NUM_DISK_MINORS)
20202020
return;
2021-
if (!unit[drive].disk[type]) {
2022-
if (ataflop_alloc_disk(drive, type) == 0) {
2023-
add_disk(unit[drive].disk[type]);
2024-
unit[drive].registered[type] = true;
2025-
}
2026-
}
2021+
if (unit[drive].disk[type])
2022+
return
2023+
if (ataflop_alloc_disk(drive, type))
2024+
return;
2025+
if (add_disk(unit[drive].disk[type]))
2026+
goto cleanup_disk;
2027+
unit[drive].registered[type] = true;
2028+
return;
2029+
2030+
cleanup_disk:
2031+
blk_cleanup_disk(unit[drive].disk[type]);
2032+
unit[drive].disk[type] = NULL;
20272033
}
20282034

20292035
static void atari_floppy_cleanup(void)

0 commit comments

Comments
 (0)