]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: phy: clean the sfp upstream if phy probing fails
authorMaxime Chevallier <maxime.chevallier@bootlin.com>
Thu, 4 Jun 2026 09:28:15 +0000 (11:28 +0200)
committerJakub Kicinski <kuba@kernel.org>
Tue, 9 Jun 2026 00:43:27 +0000 (17:43 -0700)
Sashiko reported that we don't call sfp_bus_del_upstream() in the probe
failure path, so let's add it, otherwise the sfp-bus is left with a
dangling 'upstream' field, that may be used later on during SFP events.

This issue existed before the generic phylib sfp support, back when
drivers were calling phy_sfp_probe themselves.

Reviewed-by: Nicolai Buchwitz <nb@tipi-net.de>
Fixes: 298e54fa810e ("net: phy: add core phylib sfp support")
Signed-off-by: Maxime Chevallier <maxime.chevallier@bootlin.com>
Link: https://patch.msgid.link/20260604092819.723505-2-maxime.chevallier@bootlin.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/phy/phy_device.c

index 3370eb822017b264cfc26881b0eade8a49e1530f..6ccbfacf7d1d2e073493731abc670abcedb3d184 100644 (file)
@@ -1718,6 +1718,9 @@ static int phy_sfp_probe(struct phy_device *phydev)
 
                ret = sfp_bus_add_upstream(bus, phydev, &sfp_phydev_ops);
                sfp_bus_put(bus);
+
+               if (ret)
+                       phydev->sfp_bus = NULL;
        }
 
        if (!ret && phydev->sfp_bus)
@@ -3775,6 +3778,9 @@ static int phy_probe(struct device *dev)
        return 0;
 
 out:
+       sfp_bus_del_upstream(phydev->sfp_bus);
+       phydev->sfp_bus = NULL;
+
        if (!phydev->is_on_sfp_module)
                phy_led_triggers_unregister(phydev);