]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
net: sfp: Always call `sfp_sm_mod_remove()` on remove
authorCsókás, Bence <csokas.bence@prolan.hu>
Wed, 5 Jun 2024 08:42:51 +0000 (10:42 +0200)
committerJakub Kicinski <kuba@kernel.org>
Fri, 7 Jun 2024 00:34:03 +0000 (17:34 -0700)
If the module is in SFP_MOD_ERROR, `sfp_sm_mod_remove()` will
not be run. As a consequence, `sfp_hwmon_remove()` is not getting
run either, leaving a stale `hwmon` device behind. `sfp_sm_mod_remove()`
itself checks `sfp->sm_mod_state` anyways, so this check was not
really needed in the first place.

Fixes: d2e816c0293f ("net: sfp: handle module remove outside state machine")
Signed-off-by: "Csókás, Bence" <csokas.bence@prolan.hu>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://lore.kernel.org/r/20240605084251.63502-1-csokas.bence@prolan.hu
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/phy/sfp.c

index 3f9cbd797fd67da94ea3d605d5b14cc239e9a91e..a5684ef5884bda2690a6a1e173b0250bbe1b3f10 100644 (file)
@@ -2429,8 +2429,7 @@ static void sfp_sm_module(struct sfp *sfp, unsigned int event)
 
        /* Handle remove event globally, it resets this state machine */
        if (event == SFP_E_REMOVE) {
-               if (sfp->sm_mod_state > SFP_MOD_PROBE)
-                       sfp_sm_mod_remove(sfp);
+               sfp_sm_mod_remove(sfp);
                sfp_sm_mod_next(sfp, SFP_MOD_EMPTY, 0);
                return;
        }