netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* buggy IFB driver change
@ 2007-01-30 21:12 David Miller
  2007-01-30 21:52 ` Jeff Garzik
  0 siblings, 1 reply; 6+ messages in thread
From: David Miller @ 2007-01-30 21:12 UTC (permalink / raw)
  To: jgarzik; +Cc: netdev, m.kozlowski


Jeff, please revert: 0c0b3ae68ec93b1db5c637d294647d1cca0df763

It's wrong.  We had a lengthy analysis of this piece of code
several months ago, and it is correct.

Consider, if we run the loop and we get an error
the following happens:

1) attempt of ifb_init_one(i) fails, therefore we should
   not try to "ifb_free_one()" on "i" since it failed
2) the loop iteration first increments "i", then it
   check for error

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.

commit 0c0b3ae68ec93b1db5c637d294647d1cca0df763
Author: Mariusz Kozlowski <m.kozlowski@tuxland.pl>
Date:   Sat Jan 27 00:00:01 2007 -0800

    net: ifb error path loop fix
    
    On error we should start freeing resources at [i-1] not [i-2].
    
    Signed-off-by: Mariusz Kozlowski <m.kozlowski@tuxland.pl>
    Cc: Jeff Garzik <jeff@garzik.org>
    Signed-off-by: Andrew Morton <akpm@osdl.org>
    Signed-off-by: Jeff Garzik <jeff@garzik.org>

diff --git a/drivers/net/ifb.c b/drivers/net/ifb.c
index ca2b21f..c4ca7c9 100644
--- a/drivers/net/ifb.c
+++ b/drivers/net/ifb.c
@@ -271,8 +271,7 @@ static int __init ifb_init_module(void)
 	for (i = 0; i < numifbs && !err; i++)
 		err = ifb_init_one(i);
 	if (err) {
-		i--;
-		while (--i >= 0)
+		while (i--)
 			ifb_free_one(i);
 	}
 

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2007-01-31  1:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-30 21:12 buggy IFB driver change David Miller
2007-01-30 21:52 ` Jeff Garzik
2007-01-30 22:12   ` David Miller
2007-01-31  0:24     ` Joe Perches
2007-01-30 22:13   ` Linus Torvalds
2007-01-30 22:21     ` David Miller

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).