Commit 5b4478f5 authored by Herton Ronaldo Krzesinski's avatar Herton Ronaldo Krzesinski Committed by Ben Hutchings

floppy: properly handle failure on add_disk loop

commit d60e7ec1 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: default avatarHerton Ronaldo Krzesinski <herton.krzesinski@canonical.com>
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
[bwh: Backported to 3.2: adjust context]
Signed-off-by: default avatarBen Hutchings <ben@decadent.org.uk>
parent ae1ab6ee
...@@ -4305,7 +4305,7 @@ static int __init floppy_init(void) ...@@ -4305,7 +4305,7 @@ static int __init floppy_init(void)
err = platform_device_register(&floppy_device[drive]); err = platform_device_register(&floppy_device[drive]);
if (err) if (err)
goto out_flush_work; goto out_remove_drives;
err = device_create_file(&floppy_device[drive].dev, err = device_create_file(&floppy_device[drive].dev,
&dev_attr_cmos); &dev_attr_cmos);
...@@ -4323,6 +4323,15 @@ static int __init floppy_init(void) ...@@ -4323,6 +4323,15 @@ static int __init floppy_init(void)
out_unreg_platform_dev: out_unreg_platform_dev:
platform_device_unregister(&floppy_device[drive]); 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: out_flush_work:
flush_work_sync(&floppy_work); flush_work_sync(&floppy_work);
if (atomic_read(&usage_count)) if (atomic_read(&usage_count))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment