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
This commit is contained in:
parent
5355286a0a
commit
3f35d5150b
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=133200
19
sys/net/if.c
19
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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user