From 66cdcdf1b17eba43970f1b437387194b251f338c Mon Sep 17 00:00:00 2001 From: Stephen Hemminger Date: Wed, 29 Oct 2003 21:05:26 -0800 Subject: [PATCH] [IPX]: Fix OOPS when ipxcfg_auto_create_interfaces is on. --- net/ipx/af_ipx.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/net/ipx/af_ipx.c b/net/ipx/af_ipx.c index 1dbc3a2b2a438..0b706f561bf38 100644 --- a/net/ipx/af_ipx.c +++ b/net/ipx/af_ipx.c @@ -326,7 +326,6 @@ void __ipxitf_down(struct ipx_interface *intrfc) if (intrfc->if_dev) dev_put(intrfc->if_dev); kfree(intrfc); - module_put(THIS_MODULE); } void ipxitf_down(struct ipx_interface *intrfc) @@ -358,6 +357,17 @@ out: return NOTIFY_DONE; } + +static __exit void ipxitf_cleanup(void) +{ + struct ipx_interface *i, *tmp; + + spin_lock_bh(&ipx_interfaces_lock); + list_for_each_entry_safe(i, tmp, &ipx_interfaces, node) + __ipxitf_put(i); + spin_unlock_bh(&ipx_interfaces_lock); +} + static void ipxitf_def_skb_handler(struct sock *sock, struct sk_buff *skb) { if (sock_queue_rcv_skb(sock, skb) < 0) @@ -888,7 +898,6 @@ static struct ipx_interface *ipxitf_alloc(struct net_device *dev, __u32 netnum, INIT_HLIST_HEAD(&intrfc->if_sklist); atomic_set(&intrfc->refcnt, 1); spin_lock_init(&intrfc->if_sklist_lock); - __module_get(THIS_MODULE); } return intrfc; @@ -1979,21 +1988,13 @@ static int __init ipx_init(void) static void __exit ipx_proto_finito(void) { - /* - * No need to worry about having anything on the ipx_interfaces list, - * when a interface is created we increment the module usage count, so - * the module will only be unloaded when there are no more interfaces - */ - if (unlikely(!list_empty(&ipx_interfaces))) - BUG(); - if (unlikely(!list_empty(&ipx_routes))) - BUG(); - ipx_proc_exit(); ipx_unregister_sysctl(); unregister_netdevice_notifier(&ipx_dev_notifier); + ipxitf_cleanup(); + unregister_snap_client(pSNAP_datalink); pSNAP_datalink = NULL; -- 2.53.0