46 lines
1.0 KiB
Diff
46 lines
1.0 KiB
Diff
From: jbeulich@novell.com
|
|
Subject: Module use count must be updated as bridges are created/destroyed
|
|
Patch-mainline: unknown
|
|
References: 267651
|
|
|
|
Otherwise 'modprobe -r' on a module having a dependency on bridge will
|
|
implicitly unload bridge, bringing down all connectivity that was using
|
|
bridges.
|
|
|
|
---
|
|
net/bridge/br_if.c | 9 +++++++++
|
|
1 file changed, 9 insertions(+)
|
|
|
|
--- a/net/bridge/br_if.c
|
|
+++ b/net/bridge/br_if.c
|
|
@@ -291,6 +291,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);
|
|
@@ -309,6 +314,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:
|
|
@@ -340,6 +347,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;
|
|
}
|
|
|