Re: [PATCH 2/6] floppy: do put_disk on current dr if blk_init_queuefails

From: Vivek Goyal
Date: Fri Aug 10 2012 - 13:24:33 EST


On Thu, Aug 09, 2012 at 04:59:47PM -0300, Herton Ronaldo Krzesinski wrote:
> If blk_init_queue fails, we do not call put_disk on the current dr
> (dr is decremented first in the error handling loop).
>
> Signed-off-by: Herton Ronaldo Krzesinski <herton.krzesinski@xxxxxxxxxxxxx>
> Cc: stable@xxxxxxxxxxxxxxx

Hi,

So for the current drive we do put_disk() here and for rest of the drives
we do it in out_put_disk:.

How about if we go through all the N_DRIVE always and do put disk as need be.

for(i = 0, i < N_DRIVE, i++) {
if (!disks[i])
continue;

if (disks[i]->queue)
blk_cleanup_queue();

if (!disk_registered[i])
disks[i]->queue = NULL;

put_disk();
}

It is little more lines of code but personally I find it easier to understand
and less error prone as future modifications take place.

Thanks
Vivek

> ---
> drivers/block/floppy.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/block/floppy.c b/drivers/block/floppy.c
> index c8d9e68..1e09e99 100644
> --- a/drivers/block/floppy.c
> +++ b/drivers/block/floppy.c
> @@ -4151,6 +4151,7 @@ static int __init do_floppy_init(void)
>
> disks[dr]->queue = blk_init_queue(do_fd_request, &floppy_lock);
> if (!disks[dr]->queue) {
> + put_disk(disks[dr]);
> err = -ENOMEM;
> goto out_put_disk;
> }
> --
> 1.7.9.5
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/