public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Andy Chiu <andy.chiu@sifive.com>
To: monstr@monstr.eu
Cc: Greentime Hu <greentime.hu@sifive.com>,
	Andy Chiu <andy.chiu@sifive.com>,
	Joe Hershberger <joe.hershberger@ni.com>,
	Ramon Fried <rfried.dev@gmail.com>,
	u-boot@lists.denx.de
Subject: [PATCH 1/3] net: xilinx: fix load access fault
Date: Thu, 20 Jan 2022 15:34:18 +0800	[thread overview]
Message-ID: <20220120073420.1887809-1-andy.chiu@sifive.com> (raw)

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


             reply	other threads:[~2022-01-20 23:16 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-20  7:34 Andy Chiu [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220120073420.1887809-1-andy.chiu@sifive.com \
    --to=andy.chiu@sifive.com \
    --cc=greentime.hu@sifive.com \
    --cc=joe.hershberger@ni.com \
    --cc=monstr@monstr.eu \
    --cc=rfried.dev@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox