From 21628eb54c74ada352cf04c70b392e28705173f8 Mon Sep 17 00:00:00 2001 From: pjd Date: Thu, 15 Sep 2005 14:10:41 +0000 Subject: [PATCH] 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) --- sys/dev/bge/if_bge.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/sys/dev/bge/if_bge.c b/sys/dev/bge/if_bge.c index be8c7860a4c1..c4ae6b47f7cd 100644 --- a/sys/dev/bge/if_bge.c +++ b/sys/dev/bge/if_bge.c @@ -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; }