Skip to content

Commit

Permalink
ataflop: 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-13-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 26e06f5 commit 46a7db4
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions drivers/block/ataflop.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 46a7db4

Please sign in to comment.