From: "Jan Beulich" <JBeulich@novell.com>
To: <shemminger@linux-foundation.org>
Cc: <bridge@lists.linux-foundation.org>,
"Jeff Mahoney" <jeffm@suse.com>, <netdev@vger.kernel.org>
Subject: [PATCH] bridge: Module use count must be updated as bridges are created/destroyed
Date: Fri, 29 Apr 2011 08:21:14 +0100 [thread overview]
Message-ID: <4DBA830A020000780003ED5D@vpn.id2.novell.com> (raw)
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;
}
next reply other threads:[~2011-04-29 7:21 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-04-29 7:21 Jan Beulich [this message]
2011-04-29 7:25 ` [PATCH] bridge: Module use count must be updated as bridges are created/destroyed 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4DBA830A020000780003ED5D@vpn.id2.novell.com \
--to=jbeulich@novell.com \
--cc=bridge@lists.linux-foundation.org \
--cc=jeffm@suse.com \
--cc=netdev@vger.kernel.org \
--cc=shemminger@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).