[Devel,RHEL7,COMMIT] ms/macvlan: unregister net device when netdev_upper_dev_link() fails

Submitted by Konstantin Khorenko on Jan. 11, 2017, 4:19 p.m.

Details

Message ID 201701111619.v0BGJbhZ012321@finist_cl7.x64_64.work.ct
State New
Series "macvlan: fix crash on list_del_rcu in macvlan_dellink"
Headers show

Commit Message

Konstantin Khorenko Jan. 11, 2017, 4:19 p.m.
The commit is pushed to "branch-rh7-3.10.0-514.vz7.27.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-514.vz7.27.9
------>
commit 5fdf0a73250e93877a68d57948f4237134d0d522
Author: Cong Wang <cwang@twopensource.com>
Date:   Wed Jan 11 20:19:37 2017 +0400

    ms/macvlan: unregister net device when netdev_upper_dev_link() fails
    
    rtnl_newlink() doesn't unregister it for us on failure.
    
    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>
    
    ms commit: da37705 ("macvlan: unregister net device when
    netdev_upper_dev_link() fails")
    
    https://jira.sw.ru/browse/PSBM-58300
    
    Signed-off-by: Pavel Tikhomirov <ptikhomirov@virtuozzo.com>
    Acked-by: Andrew Vagin <avagin@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)