From: Nicolas Dichtel Date: Tue, 20 Jan 2015 14:15:42 +0000 (+0100) Subject: rtnl: fix error path when adding an iface with a link net X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=bdef279b993b3a112c493447d5b3d8f28c229d88;p=linux-beck.git rtnl: fix error path when adding an iface with a link net If an error occurs when the netdevice is moved to the link netns, a full cleanup must be done. Fixes: 317f4810e45e ("rtnl: allow to create device with IFLA_LINK_NETNSID set") Signed-off-by: Nicolas Dichtel Signed-off-by: David S. Miller --- diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index a12eecc0f976..07447d1665e6 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -2172,8 +2172,11 @@ replay: goto out; } - if (link_net) + if (link_net) { err = dev_change_net_namespace(dev, dest_net, ifname); + if (err < 0) + unregister_netdevice(dev); + } out: if (link_net) put_net(link_net);