diff options
author | Herton Ronaldo Krzesinski <herton.krzesinski@canonical.com> | 2012-08-27 19:56:54 -0400 |
---|---|---|
committer | Jens Axboe <axboe@kernel.dk> | 2012-10-30 03:34:25 -0400 |
commit | d60e7ec18c3fb2cbf90969ccd42889eb2d03aef9 (patch) | |
tree | 05ebf2276e545a301eb3e6db2264254b11c3ae1e /drivers/block | |
parent | 238ab78469c6ab7845b43d5061cd3c92331b2452 (diff) |
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')
-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) | |||
4292 | 4292 | ||
4293 | err = platform_device_register(&floppy_device[drive]); | 4293 | err = platform_device_register(&floppy_device[drive]); |
4294 | if (err) | 4294 | if (err) |
4295 | goto out_release_dma; | 4295 | goto out_remove_drives; |
4296 | 4296 | ||
4297 | err = device_create_file(&floppy_device[drive].dev, | 4297 | err = device_create_file(&floppy_device[drive].dev, |
4298 | &dev_attr_cmos); | 4298 | &dev_attr_cmos); |
@@ -4310,6 +4310,15 @@ static int __init do_floppy_init(void) | |||
4310 | 4310 | ||
4311 | out_unreg_platform_dev: | 4311 | out_unreg_platform_dev: |
4312 | platform_device_unregister(&floppy_device[drive]); | 4312 | platform_device_unregister(&floppy_device[drive]); |
4313 | out_remove_drives: | ||
4314 | while (drive--) { | ||
4315 | if ((allowed_drive_mask & (1 << drive)) && | ||
4316 | fdc_state[FDC(drive)].version != FDC_NONE) { | ||
4317 | del_gendisk(disks[drive]); | ||
4318 | device_remove_file(&floppy_device[drive].dev, &dev_attr_cmos); | ||
4319 | platform_device_unregister(&floppy_device[drive]); | ||
4320 | } | ||
4321 | } | ||
4313 | out_release_dma: | 4322 | out_release_dma: |
4314 | if (atomic_read(&usage_count)) | 4323 | if (atomic_read(&usage_count)) |
4315 | floppy_release_irq_and_dma(); | 4324 | floppy_release_irq_and_dma(); |