qubes-linux-kernel/patches.fixes/bridge-module-get-put.patch

46 lines
1.0 KiB
Diff
Raw Normal View History

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
@@ -279,6 +279,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);
@@ -297,6 +302,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:
@@ -328,6 +335,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;
}