diff options
-rw-r--r-- | sys/net/if.c | 19 | ||||
-rw-r--r-- | sys/pci/if_xl.c | 6 |
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); } |