diff options
author | Justin Hibbits <jhibbits@FreeBSD.org> | 2022-11-26 15:38:13 +0000 |
---|---|---|
committer | Justin Hibbits <jhibbits@FreeBSD.org> | 2022-11-26 15:55:21 +0000 |
commit | 21d5b592faa1cd71c201acfb2686b79e0bbba9f7 (patch) | |
tree | 30b683b30553918a8bd5d470827437b3d776cf31 /sys/dev/dpaa | |
parent | f93d92f43d984c1d927c7c12d06ae1497d12deea (diff) | |
download | src-21d5b592faa1cd71c201acfb2686b79e0bbba9f7.tar.gz src-21d5b592faa1cd71c201acfb2686b79e0bbba9f7.zip |
dpaa: Account for MDIO device not being found
It's possible the MDIO device hasn't been and attached, or is incorrect
in the device tree so can't probe and attach. In this case,
ofw_bus_find_child_device_by_phandle() will fail, and return NULL.
Return an error from find_mdio() here to prevent the MAC from attaching,
rather than worry about a NULL pointer dereference later on when
accessing the PHY.
Diffstat (limited to 'sys/dev/dpaa')
-rw-r--r-- | sys/dev/dpaa/if_dtsec_fdt.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/sys/dev/dpaa/if_dtsec_fdt.c b/sys/dev/dpaa/if_dtsec_fdt.c index 67f34683b66a..1ab331caf0d1 100644 --- a/sys/dev/dpaa/if_dtsec_fdt.c +++ b/sys/dev/dpaa/if_dtsec_fdt.c @@ -125,6 +125,9 @@ find_mdio(phandle_t phy_node, device_t mac, device_t *mdio_dev) bus = device_get_parent(mac); *mdio_dev = ofw_bus_find_child_device_by_phandle(bus, phy_node); + if (*mdio_dev == NULL) + return (ENOENT); + return (0); } |