@@ -4522,6 +4522,7 @@ static void floppy_probe(dev_t dev)
{
unsigned int drive = (MINOR(dev) & 3) | ((MINOR(dev) & 0x80) >> 5);
unsigned int type = (MINOR(dev) >> 2) & 0x1f;
+ int err = 0;
if (drive >= N_DRIVE || !floppy_available(drive) ||
type >= ARRAY_SIZE(floppy_type))
@@ -4529,10 +4530,20 @@ static void floppy_probe(dev_t dev)
mutex_lock(&floppy_probe_lock);
if (!disks[drive][type]) {
- if (floppy_alloc_disk(drive, type) == 0)
- add_disk(disks[drive][type]);
+ err = floppy_alloc_disk(drive, type);
+ if (err == 0) {
+ err = add_disk(disks[drive][type]);
+ if (err)
+ goto err_out;
+ }
}
mutex_unlock(&floppy_probe_lock);
+ return;
+
+err_out:
+ blk_cleanup_disk(disks[drive][type]);
+ disks[drive][type] = NULL;
+ mutex_unlock(&floppy_probe_lock);
}
static int __init do_floppy_init(void)
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@kernel.org> --- drivers/block/floppy.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-)