mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] Module use count must be updated as bridges are created/destroyed
@ 2007-09-26  7:53 Jan Beulich
  2007-09-26 15:37 ` Stephen Hemminger
  0 siblings, 1 reply; 18+ messages in thread
From: Jan Beulich @ 2007-09-26  7:53 UTC (permalink / raw)
  To: shemminger; +Cc: bridge, linux-kernel

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>

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

--- linux-2.6.23-rc8/net/bridge/br_if.c	2007-09-26 09:23:54.000000000 +0200
+++ 2.6.23-rc8-bridge-module-get-put/net/bridge/br_if.c	2007-09-25 14:31:01.000000000 +0200
@@ -276,6 +276,11 @@ int br_add_bridge(const char *name)
 	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);
@@ -294,6 +299,8 @@ int br_add_bridge(const char *name)
 		unregister_netdevice(dev);
  out:
 	rtnl_unlock();
+	if (ret)
+		module_put(THIS_MODULE);
 	return ret;
 }
 
@@ -321,6 +328,8 @@ int br_del_bridge(const char *name)
 		del_br(netdev_priv(dev));
 
 	rtnl_unlock();
+	if (ret == 0)
+		module_put(THIS_MODULE);
 	return ret;
 }
 




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

end of thread, other threads:[~2007-09-29  0:55 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-09-26  7:53 [PATCH] Module use count must be updated as bridges are created/destroyed Jan Beulich
2007-09-26 15:37 ` Stephen Hemminger
2007-09-26 21:06   ` why network devices don't do reference counting? (Re: [PATCH] Module use count must be updated as bridges are created/destroyed) Oleg Verych
2007-09-26 21:06     ` Stephen Hemminger
2007-09-26 22:18       ` Jan Engelhardt
2007-09-26 22:33         ` Stephen Hemminger
2007-09-26 22:57           ` why network devices don't do reference counting? David Miller
2007-09-27 11:54           ` why network devices don't do reference counting? (Re: [PATCH] Module use count must be updated as bridges are created/destroyed) Helge Hafting
2007-09-27 14:51             ` Stephen Hemminger
2007-09-27 14:55               ` Jan Engelhardt
2007-09-27 19:15                 ` why network devices don't do reference counting? David Miller
2007-09-27 19:01             ` David Miller
     [not found]   ` <46FAA013.76E4.0078.0@novell.com>
     [not found]     ` <20070926101252.3ccbb987@freepuppy.rosehill>
2007-09-27  7:40       ` [PATCH] Module use count must be updated as bridges are created/destroyed Jan Beulich
2007-09-27 14:48         ` Stephen Hemminger
2007-09-27 15:05           ` Jan Beulich
2007-09-28  5:37             ` Herbert Xu
2007-09-28 18:11               ` Stephen Hemminger
2007-09-29  0:55                 ` Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome