diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c index a5811b427680..c4528f5349a3 100644 --- a/net/core/rtnetlink.c +++ b/net/core/rtnetlink.c @@ -637,16 +637,15 @@ int rtnl_link_register(struct rtnl_link_ops *ops) } EXPORT_SYMBOL_GPL(rtnl_link_register); -static void __rtnl_kill_links(struct net *net, struct rtnl_link_ops *ops) +static void __rtnl_kill_links(struct net *net, struct rtnl_link_ops *ops, + struct list_head *dev_kill_list) { struct net_device *dev; - LIST_HEAD(list_kill); for_each_netdev(net, dev) { if (dev->rtnl_link_ops == ops) - ops->dellink(dev, &list_kill); + ops->dellink(dev, dev_kill_list); } - unregister_netdevice_many(&list_kill); } /* Return with the rtnl_lock held when there are no network @@ -677,6 +676,7 @@ static void rtnl_lock_unregistering_all(void) */ void rtnl_link_unregister(struct rtnl_link_ops *ops) { + LIST_HEAD(dev_kill_list); struct net *net; mutex_lock(&link_ops_mutex); @@ -691,7 +691,9 @@ void rtnl_link_unregister(struct rtnl_link_ops *ops) rtnl_lock_unregistering_all(); for_each_net(net) - __rtnl_kill_links(net, ops); + __rtnl_kill_links(net, ops, &dev_kill_list); + + unregister_netdevice_many(&dev_kill_list); rtnl_unlock(); up_write(&pernet_ops_rwsem);