From: Greentime Hu <greentime...@sifive.com> phy_connect() may fail by returning a NULL pointer. Thus, axiemac_phy_init() should handle the case or we may get an access fault when it tries to dereference it.
Signed-off-by: Greentime Hu <greentime...@sifive.com> Reviewed-by: Andy Chiu <andy.c...@sifive.com> Signed-off-by: Andy Chiu <andy.c...@sifive.com> --- drivers/net/xilinx_axi_emac.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/xilinx_axi_emac.c b/drivers/net/xilinx_axi_emac.c index 2ec76d0f52..3117dae05e 100644 --- a/drivers/net/xilinx_axi_emac.c +++ b/drivers/net/xilinx_axi_emac.c @@ -312,6 +312,10 @@ static int axiemac_phy_init(struct udevice *dev) /* Interface - look at tsec */ phydev = phy_connect(priv->bus, priv->phyaddr, dev, priv->interface); + if (!phydev) { + printf("phy_connect failed\n"); + return -ENODEV; + } phydev->supported &= supported; phydev->advertising = phydev->supported; -- 2.34.1