Re: [patch] [bugfix] loop.c

From: Al Viro
Date: Fri Mar 23 2007 - 10:56:41 EST


On Fri, Mar 23, 2007 at 03:48:09PM +0100, Eric Dumazet wrote:
> On Fri, 23 Mar 2007 14:36:05 +0000
> Al Viro <viro@xxxxxxxxxxxxxxxx> wrote:
>
> > On Fri, Mar 23, 2007 at 03:19:56PM +0100, Eric Dumazet wrote:
> > > I cooked the following patch (untested), feel free to test it.
> >
> > Please, get the cleanup into saner shape. This is too ugly.
>
> out_mem:
> while (nba--)
> blk_cleanup_queue(loop_dev[nba]->lo_queue);
> while (nbl--) {
> put_disk(loop_dev[nbl]->lo_disk);
> kfree(loop_dev[nbl]);
> }
> if (loop_dev_vmalloced)
> vfree(loop_dev);
> else
> kfree(loop_dev);
> unregister_blkdev(LOOP_MAJOR, "loop");
>
>
> What is ugly in this code ?

Your counters. Two loops instead of one (no reason to allocate queues in
a a separate loop). vmalloc conditional on kmalloc failure.
-
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/