[Devel,RH7,3/3] macvlan: unregister net device when netdev_upper_dev_link() fails

Submitted by Pavel Tikhomirov on Jan. 10, 2017, 1:36 p.m.

Details

Message ID 20170110133627.19553-4-ptikhomirov@virtuozzo.com
State New
Series "macvlan: fix crash on list_del_rcu in macvlan_dellink"
Headers show

Commit Message

Pavel Tikhomirov Jan. 10, 2017, 1:36 p.m.
From: Cong Wang <cwang@twopensource.com>

rtnl_newlink() doesn't unregister it for us on failure.

https://jira.sw.ru/browse/PSBM-58300

Cc: Patrick McHardy <kaber@trash.net>
Cc: David S. Miller <davem@davemloft.net>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
Signed-off-by: Cong Wang <cwang@twopensource.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
---
 drivers/net/macvlan.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index a6bbb1d..808cf38 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -966,8 +966,7 @@  int macvlan_common_newlink(struct net *src_net, struct net_device *dev,
 
 	err = netdev_upper_dev_link(lowerdev, dev);
 	if (err)
-		goto destroy_port;
-
+		goto unregister_netdev;
 
 	dev->priv_flags |= IFF_MACVLAN;
 	list_add_tail_rcu(&vlan->list, &port->vlans);
@@ -975,6 +974,8 @@  int macvlan_common_newlink(struct net *src_net, struct net_device *dev,
 
 	return 0;
 
+unregister_netdev:
+	unregister_netdevice(dev);
 destroy_port:
 	port->count -= 1;
 	if (!port->count)