Skip to content

Commit

Permalink
floppy: address add_disk() error handling on probe
Browse files Browse the repository at this point in the history
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-14-mcgrof@kernel.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
  • Loading branch information
Luis Chamberlain authored and Jens Axboe committed Nov 4, 2021
1 parent 46a7db4 commit ec28fcc
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions drivers/block/floppy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down

0 comments on commit ec28fcc

Please sign in to comment.