Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/dev/mii Do not deref a NULL pointer if no current media ...
details: https://anonhg.NetBSD.org/src/rev/01afad70e834
branches: trunk
changeset: 826048:01afad70e834
user: martin <martin%NetBSD.org@localhost>
date: Sat Aug 12 11:21:15 2017 +0000
description:
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:
sys/dev/mii/nsphy.c | 10 +++++-----
1 files changed, 5 insertions(+), 5 deletions(-)
diffs (45 lines):
diff -r 07c0154b9ff6 -r 01afad70e834 sys/dev/mii/nsphy.c
--- a/sys/dev/mii/nsphy.c Sat Aug 12 11:03:47 2017 +0000
+++ b/sys/dev/mii/nsphy.c Sat Aug 12 11:21:15 2017 +0000
@@ -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 @@
/*
* 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 @@
* 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 @@
/*
* 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)
Home |
Main Index |
Thread Index |
Old Index