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

Pavel Tikhomirov ptikhomirov at virtuozzo.com
Tue Jan 10 05:36:27 PST 2017


From: Cong Wang <cwang at twopensource.com>

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

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

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

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)
-- 
2.9.3



More information about the Devel mailing list