[U-Boot] [PATCH v2 18/20] net: mvneta: Fix fault when wrong device tree

Marek BehĂșn marek.behun at nic.cz
Tue Apr 24 15:21:29 UTC 2018


The driver does not check id phy_connect failed (for example on wrong
property name in device tree). In such a case a fault occurs and the
CPU is restarted.

Signed-off-by: Marek Behun <marek.behun at nic.cz>
Reviewed-by: Stefan Roese <sr at denx.de>
---
 drivers/net/mvneta.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/mvneta.c b/drivers/net/mvneta.c
index f2e9acfd1f..7ea61ae582 100644
--- a/drivers/net/mvneta.c
+++ b/drivers/net/mvneta.c
@@ -1563,6 +1563,10 @@ static int mvneta_start(struct udevice *dev)
 
 			phydev = phy_connect(pp->bus, pp->phyaddr, dev,
 					     pp->phy_interface);
+			if (!phydev) {
+				printf("phy_connect failed\n");
+				return -ENODEV;
+			}
 
 			pp->phydev = phydev;
 			phy_config(phydev);
-- 
2.16.1



More information about the U-Boot mailing list