summaryrefslogtreecommitdiffstats
path: root/sys/dev/mii/mii.c
diff options
context:
space:
mode:
authormjacob <mjacob@FreeBSD.org>2001-10-01 22:57:57 +0000
committermjacob <mjacob@FreeBSD.org>2001-10-01 22:57:57 +0000
commitcd878c913ca7169edd42457d654151c658c18b46 (patch)
tree39a9197df9746603c2e69abdf4633370aa656416 /sys/dev/mii/mii.c
parent34e7592a675c40585af2983d15f65c01cf488a6d (diff)
downloadFreeBSD-src-cd878c913ca7169edd42457d654151c658c18b46.zip
FreeBSD-src-cd878c913ca7169edd42457d654151c658c18b46.tar.gz
Note the 'common knowledge' assumption that each NIC's softc starts
with an ifnet structure (so device_get_softc will get one). If memory allocation fails in mii_phy_probe, don't just march ahead into a panic- return ENOMEM. MFC after: 1 week
Diffstat (limited to 'sys/dev/mii/mii.c')
-rw-r--r--sys/dev/mii/mii.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/sys/dev/mii/mii.c b/sys/dev/mii/mii.c
index e463b75..300727e 100644
--- a/sys/dev/mii/mii.c
+++ b/sys/dev/mii/mii.c
@@ -167,6 +167,9 @@ int miibus_attach(dev)
struct mii_data *mii;
mii = device_get_softc(dev);
+ /*
+ * Note that each NIC's softc must start with an ifnet structure.
+ */
mii->mii_ifp = device_get_softc(device_get_parent(dev));
v = device_get_ivars(dev);
ifmedia_upd = v[0];
@@ -233,6 +236,9 @@ miibus_linkchg(dev)
MIIBUS_LINKCHG(parent);
mii = device_get_softc(dev);
+ /*
+ * Note that each NIC's softc must start with an ifnet structure.
+ */
ifp = device_get_softc(parent);
if (mii->mii_media_status & IFM_AVALID) {
@@ -279,6 +285,9 @@ int mii_phy_probe(dev, child, ifmedia_upd, ifmedia_sts)
int bmsr, i;
v = malloc(sizeof(vm_offset_t) * 2, M_DEVBUF, M_NOWAIT);
+ if (v == 0) {
+ return (ENOMEM);
+ }
v[0] = ifmedia_upd;
v[1] = ifmedia_sts;
*child = device_add_child(dev, "miibus", -1);
OpenPOWER on IntegriCloud