diff options
author | Luis Chamberlain <mcgrof@kernel.org> | 2021-09-28 00:02:54 +0200 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2021-10-18 22:41:37 +0200 |
commit | a2379420c7d7cb14a8b214fc7c0e2f55f66393ac (patch) | |
tree | cc6e6287a8d5d080603270539d165b30f4ada04f /drivers/block/amiflop.c | |
parent | floppy: add error handling support for add_disk() (diff) | |
download | linux-a2379420c7d7cb14a8b214fc7c0e2f55f66393ac.tar.xz linux-a2379420c7d7cb14a8b214fc7c0e2f55f66393ac.zip |
amiflop: add error handling support for add_disk()
We never checked for errors on add_disk() as this function
returned void. Now that this is fixed, use the shiny new
error handling. The caller for fd_alloc_disk() deals with
the rest of the cleanup like the tag.
Signed-off-by: Luis Chamberlain <mcgrof@kernel.org>
Link: https://lore.kernel.org/r/20210927220302.1073499-7-mcgrof@kernel.org
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/block/amiflop.c')
-rw-r--r-- | drivers/block/amiflop.c | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/drivers/block/amiflop.c b/drivers/block/amiflop.c index 2909fd9e72fb..bf5c124c5452 100644 --- a/drivers/block/amiflop.c +++ b/drivers/block/amiflop.c @@ -1780,6 +1780,7 @@ static const struct blk_mq_ops amiflop_mq_ops = { static int fd_alloc_disk(int drive, int system) { struct gendisk *disk; + int err; disk = blk_mq_alloc_disk(&unit[drive].tag_set, NULL); if (IS_ERR(disk)) @@ -1798,8 +1799,10 @@ static int fd_alloc_disk(int drive, int system) set_capacity(disk, 880 * 2); unit[drive].gendisk[system] = disk; - add_disk(disk); - return 0; + err = add_disk(disk); + if (err) + blk_cleanup_disk(disk); + return err; } static int fd_alloc_drive(int drive) |