summaryrefslogtreecommitdiffstats
path: root/sys
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
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')
-rw-r--r--sys/net/if.c19
-rw-r--r--sys/pci/if_xl.c6
2 files changed, 19 insertions, 6 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);
diff --git a/sys/pci/if_xl.c b/sys/pci/if_xl.c
index 700c98d..95edcfa 100644
--- a/sys/pci/if_xl.c
+++ b/sys/pci/if_xl.c
@@ -3169,7 +3169,8 @@ xl_stop(struct xl_softc *sc)
sc->xl_cdata.xl_rx_chain[i].xl_mbuf = NULL;
}
}
- bzero(sc->xl_ldata.xl_rx_list, XL_RX_LIST_SZ);
+ if (sc->xl_ldata.xl_rx_list != NULL)
+ bzero(sc->xl_ldata.xl_rx_list, XL_RX_LIST_SZ);
/*
* Free the TX list buffers.
*/
@@ -3183,7 +3184,8 @@ xl_stop(struct xl_softc *sc)
sc->xl_cdata.xl_tx_chain[i].xl_mbuf = NULL;
}
}
- bzero(sc->xl_ldata.xl_tx_list, XL_TX_LIST_SZ);
+ if (sc->xl_ldata.xl_tx_list != NULL)
+ bzero(sc->xl_ldata.xl_tx_list, XL_TX_LIST_SZ);
ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
}
OpenPOWER on IntegriCloud