[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1344915083.824.182.camel@deadeye.wl.decadent.org.uk>
Date: Tue, 14 Aug 2012 04:31:23 +0100
From: Ben Hutchings <ben@...adent.org.uk>
To: Herton Ronaldo Krzesinski <herton.krzesinski@...onical.com>
Cc: Jiri Kosina <jkosina@...e.cz>,
Andrew Morton <akpm@...ux-foundation.org>,
Jens Axboe <axboe@...nel.dk>, Tejun Heo <tj@...nel.org>,
linux-kernel@...r.kernel.org, Vivek Goyal <vgoyal@...hat.com>
Subject: Re: [PATCH v3 4/6] floppy: properly handle failure on add_disk loop
On Mon, 2012-08-13 at 15:16 -0300, Herton Ronaldo Krzesinski wrote:
> On do_floppy_init, if something failed inside the loop we call add_disk,
> there was no cleanup of previous iterations in the error handling.
>
> Cc: stable@...r.kernel.org
> Acked-by: Vivek Goyal <vgoyal@...hat.com>
> Signed-off-by: Herton Ronaldo Krzesinski <herton.krzesinski@...onical.com>
This depends on 3/6. If that's replaced by my proposed fix, then:
> ---
> drivers/block/floppy.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
> index 9272203..3eafe93 100644
> --- a/drivers/block/floppy.c
> +++ b/drivers/block/floppy.c
> @@ -4294,7 +4294,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);
> @@ -4313,6 +4313,14 @@ static int __init do_floppy_init(void)
>
> out_unreg_platform_dev:
> platform_device_unregister(&floppy_device[drive]);
> +out_remove_drives:
> + while (drive--) {
> + if (disk_registered[drive]) {
I think the test of allowed_drive_mask and FDC version before
registering each driver should be factored out into a function that you
can use here. There would then no need for the disk_registered array.
Ben.
> + 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();
--
Ben Hutchings
I say we take off; nuke the site from orbit. It's the only way to be sure.
Download attachment "signature.asc" of type "application/pgp-signature" (829 bytes)
Powered by blists - more mailing lists