summaryrefslogtreecommitdiff
path: root/net/core
diff options
context:
space:
mode:
authorWANG Cong <xiyou.wangcong@gmail.com>2015-02-13 13:56:53 -0800
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-03-18 14:10:49 +0100
commit2f3b6173e44a8add131deffe49c556472301f281 (patch)
treea0dd72415a67e637f2a9e929f37596f2490cd97f /net/core
parent29ec76704d111f747e5640ce3998611c5407049b (diff)
downloadlwn-2f3b6173e44a8add131deffe49c556472301f281.tar.gz
lwn-2f3b6173e44a8add131deffe49c556472301f281.zip
rtnetlink: call ->dellink on failure when ->newlink exists
[ Upstream commit 7afb8886a05be68e376655539a064ec672de8a8e ] Ignacy reported that when eth0 is down and add a vlan device on top of it like: ip link add link eth0 name eth0.1 up type vlan id 1 We will get a refcount leak: unregister_netdevice: waiting for eth0.1 to become free. Usage count = 2 The problem is when rtnl_configure_link() fails in rtnl_newlink(), we simply call unregister_device(), but for stacked device like vlan, we almost do nothing when we unregister the upper device, more work is done when we unregister the lower device, so call its ->dellink(). Reported-by: Ignacy Gawedzki <ignacy.gawedzki@green-communications.fr> Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net/core')
-rw-r--r--net/core/rtnetlink.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index 5daabfda6f6f..d582e67a6ee0 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -2124,8 +2124,16 @@ replay:
}
}
err = rtnl_configure_link(dev, ifm);
- if (err < 0)
- unregister_netdevice(dev);
+ if (err < 0) {
+ if (ops->newlink) {
+ LIST_HEAD(list_kill);
+
+ ops->dellink(dev, &list_kill);
+ unregister_netdevice_many(&list_kill);
+ } else {
+ unregister_netdevice(dev);
+ }
+ }
out:
put_net(dest_net);
return err;