summaryrefslogtreecommitdiffstats
path: root/sys/dev/mii/atphy.c
diff options
context:
space:
mode:
authormarius <marius@FreeBSD.org>2010-11-18 17:58:59 +0000
committermarius <marius@FreeBSD.org>2010-11-18 17:58:59 +0000
commitf38659ee6b9761cae909a360538194fdcd00e2bb (patch)
tree64cd709009100266e85b2ddeaa479ec6299a67e2 /sys/dev/mii/atphy.c
parent60be074c5c105702a13e91589efecad633d770fd (diff)
downloadFreeBSD-src-f38659ee6b9761cae909a360538194fdcd00e2bb.zip
FreeBSD-src-f38659ee6b9761cae909a360538194fdcd00e2bb.tar.gz
Fix a bug introduced with r215298; when atphy_reset() is called from
atphy_attach() the current media has not been set, yet, leading to a NULL-dereference in atphy_setmedia(). Submitted by: jkim (initial version)
Diffstat (limited to 'sys/dev/mii/atphy.c')
-rw-r--r--sys/dev/mii/atphy.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/sys/dev/mii/atphy.c b/sys/dev/mii/atphy.c
index cfabd21..07847be 100644
--- a/sys/dev/mii/atphy.c
+++ b/sys/dev/mii/atphy.c
@@ -317,6 +317,7 @@ atphy_status(struct mii_softc *sc)
static void
atphy_reset(struct mii_softc *sc)
{
+ struct ifmedia_entry *ife = sc->mii_pdata->mii_media.ifm_cur;
struct atphy_softc *asc;
uint32_t reg;
int i;
@@ -339,7 +340,7 @@ atphy_reset(struct mii_softc *sc)
PHY_WRITE(sc, ATPHY_SCR, reg);
/* Workaround F1 bug to reset phy. */
- atphy_setmedia(sc, sc->mii_pdata->mii_media.ifm_cur->ifm_media);
+ atphy_setmedia(sc, ife == NULL ? IFM_AUTO : ife->ifm_media);
for (i = 0; i < 1000; i++) {
DELAY(1);
OpenPOWER on IntegriCloud