From: Maxime Chevallier Date: Thu, 4 Jun 2026 09:28:17 +0000 (+0200) Subject: net: phy: Clean the phy_ports after unregistering the downstream SFP bus X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=4497f5028675b7e51c4aa59c3f4df01f29424277;p=thirdparty%2Fkernel%2Flinux.git net: phy: Clean the phy_ports after unregistering the downstream SFP bus As reported by sashiko when looking a other patches, we need to ensure that the downstream SFP bus gets unregistered prior to destroying the phy_ports attached to a phy_device, as the SFP code may reference these ports. Let's make sure we follow that ordering in phy_remove(). Fixes: 589e934d2735 ("net: phy: Introduce PHY ports representation") Signed-off-by: Maxime Chevallier Reviewed-by: Nicolai Buchwitz Link: https://patch.msgid.link/20260604092819.723505-4-maxime.chevallier@bootlin.com Signed-off-by: Jakub Kicinski --- diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 4ba880446896..b48722589f40 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -3806,11 +3806,11 @@ static int phy_remove(struct device *dev) phydev->state = PHY_DOWN; - phy_cleanup_ports(phydev); - sfp_bus_del_upstream(phydev->sfp_bus); phydev->sfp_bus = NULL; + phy_cleanup_ports(phydev); + if (phydev->drv && phydev->drv->remove) phydev->drv->remove(phydev);