Thread (8 messages) flat view 8 messages, 2 authors, 1d ago
WARM1d

Revision v2 of 2 in this series.

Revisions (2)
  1. v2 current
  2. v3 [diff vs current]

[PATCH net v2 3/5] net: phy: restore device state after probe failure

From: Xuanqiang Luo <hidden>
Date: 2026-08-13 13:30:23
Also in: lkml
Subsystem: ethernet phy library, networking drivers, the rest · Maintainers: Andrew Lunn, Heiner Kallweit, Andrew Lunn, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds

From: Xuanqiang Luo <redacted>

phy_probe() sets phydev->drv before calling the PHY driver probe
callback, but does not clear it if probing later fails. It also sets
PHY_READY before of_phy_leds(), leaving the state ready if LED setup
fails.

Clear phydev->drv on every error path and restore PHY_DOWN after LED
setup failure.

Fixes: 00db8189d984 ("This patch adds a PHY Abstraction Layer to the Linux Kernel, enabling ethernet drivers to remain as ignorant as is reasonable of the connected PHY's design and operation details.")
Signed-off-by: Xuanqiang Luo <redacted>
---
 drivers/net/phy/phy_device.c | 3 +++
 1 file changed, 3 insertions(+)
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 9c7ed9c61e6d5..c9e75bd3b81a2 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -3821,6 +3821,8 @@ static int phy_probe(struct device *dev)
 	if (!phydev->is_on_sfp_module)
 		phy_led_triggers_unregister(phydev);
 
+	phydev->state = PHY_DOWN;
+
 out_ports:
 	phy_sfp_release(phydev);
 	phy_cleanup_ports(phydev);
@@ -3828,6 +3830,7 @@ static int phy_probe(struct device *dev)
 out_reset:
 	/* Re-assert the reset signal on error */
 	phy_device_reset(phydev, 1);
+	phydev->drv = NULL;
 
 	return err;
 }
-- 
2.43.0
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help