On Tue, 2007-01-30 at 14:12 -0800, David Miller wrote:
> > > Therefore we must decrement "i" twice before the first
> > > free during the cleanup.  One to "undo" the for() loop
> > > increment, and one to "skip" the ifb_init_one() case which
> > > failed.

Perhaps putting the error unwind inside the for loop
is simpler and more intelligible.

diff --git a/drivers/net/ifb.c b/drivers/net/ifb.c
index ca2b21f..0b24c31 100644
--- a/drivers/net/ifb.c
+++ b/drivers/net/ifb.c
@@ -264,19 +264,20 @@ static void ifb_free_one(int index)
 
 static int __init ifb_init_module(void)
 {
-       int i, err = 0;
+       int i, err;
        ifbs = kmalloc(numifbs * sizeof(void *), GFP_KERNEL);
        if (!ifbs)
                return -ENOMEM;
-       for (i = 0; i < numifbs && !err; i++)
+       for (i = 0; i < numifbs; i++) {
                err = ifb_init_one(i);
-       if (err) {
-               i--;
-               while (--i >= 0)
-                       ifb_free_one(i);
+               if (err) {
+                       while (i > 0)
+                               ifb_free_one(--i);
+                       return err;
+               }
        }
 
-       return err;
+       return 0;
 }
 
 static void __exit ifb_cleanup_module(void)


-
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to