diff options
author | Herton Ronaldo Krzesinski <herton.krzesinski@canonical.com> | 2012-08-28 01:56:54 +0200 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2012-10-30 08:34:25 +0100 |
commit | d60e7ec18c3fb2cbf90969ccd42889eb2d03aef9 (patch) | |
tree | 05ebf2276e545a301eb3e6db2264254b11c3ae1e /drivers/block/floppy.c | |
parent | floppy: do put_disk on current dr if blk_init_queue fails (diff) | |
download | linux-d60e7ec18c3fb2cbf90969ccd42889eb2d03aef9.tar.xz linux-d60e7ec18c3fb2cbf90969ccd42889eb2d03aef9.zip |
floppy: properly handle failure on add_disk loop
On floppy initialization, if something failed inside the loop we call
add_disk, there was no cleanup of previous iterations in the error
handling.
Cc: stable@vger.kernel.org
Signed-off-by: Herton Ronaldo Krzesinski <herton.krzesinski@canonical.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/block/floppy.c')
-rw-r--r-- | drivers/block/floppy.c | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c index 9a558b63e78f..2c7257334b64 100644 --- a/drivers/block/floppy.c +++ b/drivers/block/floppy.c @@ -4292,7 +4292,7 @@ static int __init do_floppy_init(void) err = platform_device_register(&floppy_device[drive]); if (err) - goto out_release_dma; + goto out_remove_drives; err = device_create_file(&floppy_device[drive].dev, &dev_attr_cmos); @@ -4310,6 +4310,15 @@ static int __init do_floppy_init(void) out_unreg_platform_dev: platform_device_unregister(&floppy_device[drive]); +out_remove_drives: + while (drive--) { + if ((allowed_drive_mask & (1 << drive)) && + fdc_state[FDC(drive)].version != FDC_NONE) { + del_gendisk(disks[drive]); + device_remove_file(&floppy_device[drive].dev, &dev_attr_cmos); + platform_device_unregister(&floppy_device[drive]); + } + } out_release_dma: if (atomic_read(&usage_count)) floppy_release_irq_and_dma(); |