diff options
author | David S. Miller <davem@davemloft.net> | 2015-03-10 21:58:32 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2015-03-10 21:59:46 -0400 |
commit | 4363890079674db7b00cf1bb0e6fa430e846e86b (patch) | |
tree | 0b7905168810419c0fb2aa8fbead213f546257d5 /net/core/rtnetlink.c | |
parent | 7768eed8bf1d2e5eefa38c573f15f737a9824052 (diff) | |
download | blackbird-obmc-linux-4363890079674db7b00cf1bb0e6fa430e846e86b.tar.gz blackbird-obmc-linux-4363890079674db7b00cf1bb0e6fa430e846e86b.zip |
net: Handle unregister properly when netdev namespace change fails.
If rtnl_newlink() fails on it's call to dev_change_net_namespace(), we
have to make use of the ->dellink() method, if present, just like we
do when rtnl_configure_link() fails.
Fixes: 317f4810e45e ("rtnl: allow to create device with IFLA_LINK_NETNSID set")
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/core/rtnetlink.c')
-rw-r--r-- | net/core/rtnetlink.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index 25b4b5d23485..ee0608bb3bc0 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -2166,28 +2166,28 @@ replay: } } err = rtnl_configure_link(dev, ifm); - if (err < 0) { - if (ops->newlink) { - LIST_HEAD(list_kill); - - ops->dellink(dev, &list_kill); - unregister_netdevice_many(&list_kill); - } else { - unregister_netdevice(dev); - } - goto out; - } - + if (err < 0) + goto out_unregister; if (link_net) { err = dev_change_net_namespace(dev, dest_net, ifname); if (err < 0) - unregister_netdevice(dev); + goto out_unregister; } out: if (link_net) put_net(link_net); put_net(dest_net); return err; +out_unregister: + if (ops->newlink) { + LIST_HEAD(list_kill); + + ops->dellink(dev, &list_kill); + unregister_netdevice_many(&list_kill); + } else { + unregister_netdevice(dev); + } + goto out; } } |