]>
Commit | Line | Data |
---|---|---|
2cb7cef9 BS |
1 | From: jbeulich@novell.com |
2 | Subject: Module use count must be updated as bridges are created/destroyed | |
3 | Patch-mainline: unknown | |
4 | References: 267651 | |
5 | ||
6 | Otherwise 'modprobe -r' on a module having a dependency on bridge will | |
7 | implicitly unload bridge, bringing down all connectivity that was using | |
8 | bridges. | |
9 | ||
10 | --- | |
11 | net/bridge/br_if.c | 9 +++++++++ | |
12 | 1 file changed, 9 insertions(+) | |
13 | ||
14 | --- a/net/bridge/br_if.c | |
15 | +++ b/net/bridge/br_if.c | |
16 | @@ -271,6 +271,11 @@ int br_add_bridge(const char *name) | |
17 | if (!dev) | |
18 | return -ENOMEM; | |
19 | ||
20 | + if (!try_module_get(THIS_MODULE)) { | |
21 | + free_netdev(dev); | |
22 | + return -ENOENT; | |
23 | + } | |
24 | + | |
25 | rtnl_lock(); | |
26 | if (strchr(dev->name, '%')) { | |
27 | ret = dev_alloc_name(dev, dev->name); | |
28 | @@ -287,6 +292,8 @@ int br_add_bridge(const char *name) | |
29 | unregister_netdevice(dev); | |
30 | out: | |
31 | rtnl_unlock(); | |
32 | + if (ret) | |
33 | + module_put(THIS_MODULE); | |
34 | return ret; | |
35 | ||
36 | out_free: | |
37 | @@ -318,6 +325,8 @@ int br_del_bridge(const char *name) | |
38 | del_br(netdev_priv(dev)); | |
39 | ||
40 | rtnl_unlock(); | |
41 | + if (ret == 0) | |
42 | + module_put(THIS_MODULE); | |
43 | return ret; | |
44 | } | |
45 |