public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
* [PATCH 1/3] net: xilinx: fix load access fault
@ 2022-01-20  7:34 Andy Chiu
  2022-01-20  7:34 ` [PATCH 2/3] net: xilinx: Move setup of 1G MAC to a function Andy Chiu
  2022-01-20  7:34 ` [PATCH 3/3] net: xilinx: Force a probe failure if it cannot setup phy Andy Chiu
  0 siblings, 2 replies; 4+ messages in thread
From: Andy Chiu @ 2022-01-20  7:34 UTC (permalink / raw)
  To: monstr; +Cc: Greentime Hu, Andy Chiu, Joe Hershberger, Ramon Fried, u-boot

From: Greentime Hu <greentime.hu@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.hu@sifive.com>
Reviewed-by: Andy Chiu <andy.chiu@sifive.com>
Signed-off-by: Andy Chiu <andy.chiu@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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-02-09 13:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-20  7:34 [PATCH 1/3] net: xilinx: fix load access fault Andy Chiu
2022-01-20  7:34 ` [PATCH 2/3] net: xilinx: Move setup of 1G MAC to a function Andy Chiu
2022-01-20  7:34 ` [PATCH 3/3] net: xilinx: Force a probe failure if it cannot setup phy Andy Chiu
2022-02-09 13:33   ` Andy Chiu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox