diff options
| author | martin <martin@NetBSD.org> | 2017-08-12 11:21:15 +0000 |
|---|---|---|
| committer | martin <martin@NetBSD.org> | 2017-08-12 11:21:15 +0000 |
| commit | 667efbc74f1c4d7ea3e7adedcc970cb3fac56b51 (patch) | |
| tree | 425a54856a55237baf3c0347a94c692a1a231517 /sys/dev/mii | |
| parent | ca717b6088f78084a84bb9f09ffcbc4b4eb6d5c2 (diff) | |
Do not deref a NULL pointer if no current media has been selected.
This error condition does not happen with properly working hardware, but it is
no good reason for a kernel panic either.
Diffstat (limited to 'sys/dev/mii')
| -rw-r--r-- | sys/dev/mii/nsphy.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/sys/dev/mii/nsphy.c b/sys/dev/mii/nsphy.c index 4494a73c0dd..fa923d172a7 100644 --- a/sys/dev/mii/nsphy.c +++ b/sys/dev/mii/nsphy.c @@ -1,4 +1,4 @@ -/* $NetBSD: nsphy.c,v 1.60 2016/07/07 06:55:41 msaitoh Exp $ */ +/* $NetBSD: nsphy.c,v 1.61 2017/08/12 11:21:15 martin Exp $ */ /*- * Copyright (c) 1998, 1999, 2000 The NetBSD Foundation, Inc. @@ -60,7 +60,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nsphy.c,v 1.60 2016/07/07 06:55:41 msaitoh Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nsphy.c,v 1.61 2017/08/12 11:21:15 martin Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -153,7 +153,7 @@ nsphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) /* * If we're not polling our PHY instance, just return. */ - if (IFM_INST(ife->ifm_media) != sc->mii_inst) + if (ife != NULL && IFM_INST(ife->ifm_media) != sc->mii_inst) return (0); break; @@ -162,7 +162,7 @@ nsphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) * If the media indicates a different PHY instance, * isolate ourselves. */ - if (IFM_INST(ife->ifm_media) != sc->mii_inst) { + if (ife != NULL && IFM_INST(ife->ifm_media) != sc->mii_inst) { reg = PHY_READ(sc, MII_BMCR); PHY_WRITE(sc, MII_BMCR, reg | BMCR_ISO); return (0); @@ -216,7 +216,7 @@ nsphy_service(struct mii_softc *sc, struct mii_data *mii, int cmd) /* * If we're not currently selected, just return. */ - if (IFM_INST(ife->ifm_media) != sc->mii_inst) + if (ife != NULL && IFM_INST(ife->ifm_media) != sc->mii_inst) return (0); if (mii_phy_tick(sc) == EJUSTRETURN) |
