netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bridge: fix locking and memory leak in br_add_bridge
@ 2006-05-25 13:31 Jiri Benc
  2006-05-25 14:07 ` Jiri Benc
  0 siblings, 1 reply; 9+ messages in thread
From: Jiri Benc @ 2006-05-25 13:31 UTC (permalink / raw)
  To: Stephen Hemminger; +Cc: David Miller, NetDev

There are several problems in error handling in br_add_bridge:
- when dev_alloc_name fails, allocated net_device is not freed
- unregister_netdev is called when rtnl lock is held
- free_netdev is called before netdev_run_todo has a chance to be run after
  unregistering net_device

This patch should fix these issues.

Signed-off-by: Jiri Benc <jbenc@suse.cz>

---

 net/bridge/br_if.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)

--- dscape.orig/net/bridge/br_if.c
+++ dscape/net/bridge/br_if.c
@@ -306,20 +306,19 @@ int br_add_bridge(const char *name)
 
 	ret = register_netdevice(dev);
 	if (ret)
-		goto err2;
+		goto err1;
 
 	ret = br_sysfs_addbr(dev);
 	if (ret)
-		goto err3;
+		goto err2;
 	rtnl_unlock();
 	return 0;
 
- err3:
-	unregister_netdev(dev);
  err2:
-	free_netdev(dev);
+	unregister_netdevice(dev);
  err1:
 	rtnl_unlock();
+	free_netdev(dev);
 	return ret;
 }
 


-- 
Jiri Benc
SUSE Labs

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

end of thread, other threads:[~2006-06-05 23:38 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-05-25 13:31 [PATCH] bridge: fix locking and memory leak in br_add_bridge Jiri Benc
2006-05-25 14:07 ` Jiri Benc
2006-05-25 14:14   ` [PATCH v2] " Jiri Benc
2006-05-25 16:23     ` Stephen Hemminger
2006-05-26  9:08       ` Jiri Benc
2006-05-27  2:26         ` David Miller
2006-05-27  8:58           ` Jiri Benc
2006-05-27 16:45           ` [PATCH v3] " Stephen Hemminger
2006-06-05 23:38             ` 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).