aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block
diff options
context:
space:
mode:
authorHerton Ronaldo Krzesinski <herton.krzesinski@canonical.com>2012-08-27 20:56:54 -0300
committerBen Hutchings <ben@decadent.org.uk>2012-11-16 16:47:00 +0000
commit5b4478f5dabb7f764e2fce480b47204e06095a73 (patch)
treeaaa84e73da8e40f2f25752059feed4f0df326e3f /drivers/block
parentae1ab6ee65fe4cf7d6752b5aefffd97fc84984b2 (diff)
downloadkernel_samsung_smdk4412-5b4478f5dabb7f764e2fce480b47204e06095a73.zip
kernel_samsung_smdk4412-5b4478f5dabb7f764e2fce480b47204e06095a73.tar.gz
kernel_samsung_smdk4412-5b4478f5dabb7f764e2fce480b47204e06095a73.tar.bz2
floppy: properly handle failure on add_disk loop
commit d60e7ec18c3fb2cbf90969ccd42889eb2d03aef9 upstream. On floppy initialization, if something failed inside the loop we call add_disk, there was no cleanup of previous iterations in the error handling. 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> [bwh: Backported to 3.2: adjust context] Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Diffstat (limited to 'drivers/block')
-rw-r--r--drivers/block/floppy.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
index a6c3d18..7a90d4a 100644
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -4305,7 +4305,7 @@ static int __init floppy_init(void)
err = platform_device_register(&floppy_device[drive]);
if (err)
- goto out_flush_work;
+ goto out_remove_drives;
err = device_create_file(&floppy_device[drive].dev,
&dev_attr_cmos);
@@ -4323,6 +4323,15 @@ static int __init 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_flush_work:
flush_work_sync(&floppy_work);
if (atomic_read(&usage_count))