Skip to contentSkip to conversation

phy: don't crush if we have no parent

PATCH Applied Oleksij Rempel 2 participants 2 messages Aug 27, 2017 – Sep 6, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 phy: don't crush 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.

---
 drivers/net/phy/phy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/phy/phy.c +1 -1
index 7132516aa..25ae40233 100644
@@ -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);
Signature · 7 lines
2.11.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Applied
#1 lore raw
Quoted 7 lines · Oleksij Rempel

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.

---
 drivers/net/phy/phy.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks

Sascha

Quoted 23 lines
drivers/net/phy/phy.c +1 -1
index 7132516aa..25ae40233 100644
@@ -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);
Signature · 7 lines
2.11.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox