Skip to content

Commit ec28fcc

Browse files
mcgrofaxboe
authored andcommitted
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 <[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 46a7db4 commit ec28fcc

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

drivers/block/floppy.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4528,10 +4528,19 @@ static void floppy_probe(dev_t dev)
45284528
return;
45294529

45304530
mutex_lock(&floppy_probe_lock);
4531-
if (!disks[drive][type]) {
4532-
if (floppy_alloc_disk(drive, type) == 0)
4533-
add_disk(disks[drive][type]);
4534-
}
4531+
if (disks[drive][type])
4532+
goto out;
4533+
if (floppy_alloc_disk(drive, type))
4534+
goto out;
4535+
if (add_disk(disks[drive][type]))
4536+
goto cleanup_disk;
4537+
out:
4538+
mutex_unlock(&floppy_probe_lock);
4539+
return;
4540+
4541+
cleanup_disk:
4542+
blk_cleanup_disk(disks[drive][type]);
4543+
disks[drive][type] = NULL;
45354544
mutex_unlock(&floppy_probe_lock);
45364545
}
45374546

0 commit comments

Comments
 (0)