summaryrefslogtreecommitdiffstats
path: root/sys/net/if.c
diff options
context:
space:
mode:
authorroam <roam@FreeBSD.org>2004-08-06 09:08:33 +0000
committerroam <roam@FreeBSD.org>2004-08-06 09:08:33 +0000
commite8cd4126007b2c8b25d70b20bb84145d16bc3ebb (patch)
tree0e296af4379c4c2fbc36730b13a73dc6d5f874bc /sys/net/if.c
parente98b8f144564872ad28855de0670eeeb495de9f7 (diff)
downloadFreeBSD-src-e8cd4126007b2c8b25d70b20bb84145d16bc3ebb.zip
FreeBSD-src-e8cd4126007b2c8b25d70b20bb84145d16bc3ebb.tar.gz
Do not attempt to clean up data that has not been initialized yet.
This fixes two kernel panics on boot when the xl driver fails to allocate bus/port/memory resources. Reviewed by: silence on -net
Diffstat (limited to 'sys/net/if.c')
-rw-r--r--sys/net/if.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/sys/net/if.c b/sys/net/if.c
index 0944d44..9f560d3 100644
--- a/sys/net/if.c
+++ b/sys/net/if.c
@@ -518,6 +518,8 @@ if_detach(struct ifnet *ifp)
int s;
int i;
struct domain *dp;
+ struct ifnet *iter;
+ int found;
EVENTHANDLER_INVOKE(ifnet_departure_event, ifp);
/*
@@ -584,9 +586,11 @@ if_detach(struct ifnet *ifp)
/* We can now free link ifaddr. */
- ifa = TAILQ_FIRST(&ifp->if_addrhead);
- TAILQ_REMOVE(&ifp->if_addrhead, ifa, ifa_link);
- IFAFREE(ifa);
+ if (!TAILQ_EMPTY(&ifp->if_addrhead)) {
+ ifa = TAILQ_FIRST(&ifp->if_addrhead);
+ TAILQ_REMOVE(&ifp->if_addrhead, ifa, ifa_link);
+ IFAFREE(ifa);
+ }
/*
* Delete all remaining routes using this interface
@@ -618,7 +622,14 @@ if_detach(struct ifnet *ifp)
#endif /* MAC */
KNOTE(&ifp->if_klist, NOTE_EXIT);
IFNET_WLOCK();
- TAILQ_REMOVE(&ifnet, ifp, if_link);
+ found = 0;
+ TAILQ_FOREACH(iter, &ifnet, if_link)
+ if (iter == ifp) {
+ found = 1;
+ break;
+ }
+ if (found)
+ TAILQ_REMOVE(&ifnet, ifp, if_link);
IFNET_WUNLOCK();
mtx_destroy(&ifp->if_snd.ifq_mtx);
IF_AFDATA_DESTROY(ifp);
OpenPOWER on IntegriCloud