[PATCH] bridge: fix locking and memory leak in br_add_bridge

2006-05-25 Thread Jiri Benc
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 [EMAIL PROTECTED]

---

 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
-
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


Re: [PATCH] bridge: fix locking and memory leak in br_add_bridge

2006-05-25 Thread Jiri Benc
On Thu, 25 May 2006 15:31:24 +0200, Jiri Benc wrote:
   err2:
 - free_netdev(dev);
 + unregister_netdevice(dev);
   err1:
   rtnl_unlock();
 + free_netdev(dev);
   return ret;

Sorry, this is wrong. I didn't notice that br_dev_setup sets
dev-destructor to free_netdev. Corrected patch will follow.

 Jiri

-- 
Jiri Benc
SUSE Labs
-
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