From c4531782266fafe767cd913baecc8c5d270fac76 Mon Sep 17 00:00:00 2001 From: Oleksij Rempel Date: Sun, 27 Aug 2017 08:52:00 +0200 Subject: phy: don't crash if we have no parent current code will crash if DT has no PHY entry. With this patch we will test if parent exist, before testing the parent device node. Signed-off-by: Oleksij Rempel Signed-off-by: Sascha Hauer --- drivers/net/phy/phy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers') diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 7132516aa1..25ae40233e 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -323,7 +323,7 @@ static struct phy_device *of_mdio_find_phy(struct eth_device *edev) if (!IS_ENABLED(CONFIG_OFDEVICE)) return NULL; - if (!edev->parent->device_node) + if (!edev->parent || !edev->parent->device_node) return NULL; phy_node = of_parse_phandle(edev->parent->device_node, "phy-handle", 0); -- cgit v1.2.3