netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bridge: Module use count must be updated as bridges are created/destroyed
@ 2011-04-29  7:21 Jan Beulich
  2011-04-29  7:25 ` David Miller
  0 siblings, 1 reply; 12+ messages in thread
From: Jan Beulich @ 2011-04-29  7:21 UTC (permalink / raw)
  To: shemminger; +Cc: bridge, Jeff Mahoney, netdev

Otherwise 'modprobe -r' on a module having a dependency on bridge will
implicitly unload bridge, bringing down all connectivity that was using
bridges.

Signed-off-by: Jan Beulich <jbeulich@novell.com>
Cc: Jeff Mahoney <jeffm@suse.com>

---
 net/bridge/br_if.c |    9 +++++++++
 1 file changed, 9 insertions(+)

--- 2.6.39-rc5/net/bridge/br_if.c
+++ 2.6.39-rc5-bridge-module-get-put/net/bridge/br_if.c
@@ -290,6 +290,11 @@ int br_add_bridge(struct net *net, const
 	if (!dev)
 		return -ENOMEM;
 
+	if (!try_module_get(THIS_MODULE)) {
+		free_netdev(dev);
+		return -ENOENT;
+	}
+
 	rtnl_lock();
 	if (strchr(dev->name, '%')) {
 		ret = dev_alloc_name(dev, dev->name);
@@ -308,6 +313,8 @@ int br_add_bridge(struct net *net, const
 		unregister_netdevice(dev);
  out:
 	rtnl_unlock();
+	if (ret)
+		module_put(THIS_MODULE);
 	return ret;
 
 out_free:
@@ -339,6 +346,8 @@ int br_del_bridge(struct net *net, const
 		del_br(netdev_priv(dev), NULL);
 
 	rtnl_unlock();
+	if (ret == 0)
+		module_put(THIS_MODULE);
 	return ret;
 }
 




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

end of thread, other threads:[~2011-04-29 16:25 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-29  7:21 [PATCH] bridge: Module use count must be updated as bridges are created/destroyed Jan Beulich
2011-04-29  7:25 ` David Miller
2011-04-29  7:41   ` Jan Beulich
2011-04-29  8:10     ` David Miller
2011-04-29  8:31       ` Jan Beulich
2011-04-29  8:44         ` David Miller
2011-04-29  9:09           ` Jan Beulich
2011-04-29 11:08             ` Michal Marek
2011-04-29 16:05               ` Jon Masters
2011-04-29 16:07                 ` Jan Beulich
2011-04-29 16:20                   ` Jon Masters
2011-04-29 15:34   ` Stephen Hemminger

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