MFC: sys/dev/bge/if_bge.c 1.94

When bge_stop() is called from bge_detach(), mii is already NULL, so check
before trying to use it.
This fix allows to 'kldunload if_bge' without panicing.

Reviewed by:	bz
Approved by:	re (scottl)
This commit is contained in:
pjd 2005-09-15 14:10:41 +00:00
parent b5bca4807d
commit 21628eb54c

View File

@ -3749,11 +3749,16 @@ bge_stop(sc)
if (!sc->bge_tbi) {
itmp = ifp->if_flags;
ifp->if_flags |= IFF_UP;
ifm = mii->mii_media.ifm_cur;
mtmp = ifm->ifm_media;
ifm->ifm_media = IFM_ETHER|IFM_NONE;
mii_mediachg(mii);
ifm->ifm_media = mtmp;
/*
* If we are called from bge_detach(), mii is already NULL.
*/
if (mii != NULL) {
ifm = mii->mii_media.ifm_cur;
mtmp = ifm->ifm_media;
ifm->ifm_media = IFM_ETHER|IFM_NONE;
mii_mediachg(mii);
ifm->ifm_media = mtmp;
}
ifp->if_flags = itmp;
}