rtnl_unregister_ops calls __rtnl_links_kill which calls
unconditionally ops->dellink on any related interface.
However, if a module hasn't implemented dellink, this
invocation will crash.
Add a check to avoid calling dellink when NULL and rather
invoke netdevice_unregister_queue to schedule unregistering
the device as usual.
Signed-off-by: Antonio Quartulli <antonio@openvpn.net>
---
net/core/rtnetlink.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/net/core/rtnetlink.c b/net/core/rtnetlink.c
index eabfc8290f5e..be79c2a051b2 100644
--- a/net/core/rtnetlink.c
+++ b/net/core/rtnetlink.c
@@ -453,8 +453,12 @@ static void __rtnl_kill_links(struct net *net, struct rtnl_link_ops *ops)
LIST_HEAD(list_kill);
for_each_netdev(net, dev) {
- if (dev->rtnl_link_ops == ops)
- ops->dellink(dev, &list_kill);
+ if (dev->rtnl_link_ops == ops) {
+ if (ops->dellink)
+ ops->dellink(dev, &list_kill);
+ else
+ unregister_netdevice_queue(dev, &list_kill);
+ }
}
unregister_netdevice_many(&list_kill);
}--
2.44.2