Commit bdef279b authored by Nicolas Dichtel's avatar Nicolas Dichtel Committed by David S. Miller

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: 317f4810 ("rtnl: allow to create device with IFLA_LINK_NETNSID set")
Signed-off-by: default avatarNicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent d7924450
...@@ -2172,8 +2172,11 @@ static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh) ...@@ -2172,8 +2172,11 @@ static int rtnl_newlink(struct sk_buff *skb, struct nlmsghdr *nlh)
goto out; goto out;
} }
if (link_net) if (link_net) {
err = dev_change_net_namespace(dev, dest_net, ifname); err = dev_change_net_namespace(dev, dest_net, ifname);
if (err < 0)
unregister_netdevice(dev);
}
out: out:
if (link_net) if (link_net)
put_net(link_net); put_net(link_net);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment