]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: dsa: sja1105: ensure phylink_replay_link_end() will not be missed
authorVladimir Oltean <vladimir.oltean@nxp.com>
Wed, 4 Mar 2026 22:09:00 +0000 (00:09 +0200)
committerJakub Kicinski <kuba@kernel.org>
Sat, 7 Mar 2026 01:48:01 +0000 (17:48 -0800)
Most errors that can occur in sja1105_static_config_reload() are fatal
(example: fail to communicate with hardware), but not all are.

For example, sja1105_static_config_upload() -> kcalloc() may fail, and
if that happens, we have called phylink_replay_link_begin() but never
phylink_replay_link_end().

Under that circumstance, all port phylink instances are left in a state
where the resolver is stopped with the PHYLINK_DISABLE_REPLAY bit set.
We have effectively disabled link management with no way to recover from
this condition.

Avoid that situation by ensuring phylink_replay_link_begin() is always
paired with phylink_replay_link_end(), regardless of whether we faced
any errors during switch reset, configuration reload and general state
reload.

Fixes: 0b2edc531e0b ("net: dsa: sja1105: let phylink help with the replay of link callbacks")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Link: https://patch.msgid.link/20260304220900.3865120-3-vladimir.oltean@nxp.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/dsa/sja1105/sja1105_main.c

index bf720d96bad8bfe9d2a08ffda6c11beeb309f5e6..c72c2bfdcffb2e6ff3d05fd951c457c6f0e06638 100644 (file)
@@ -2341,10 +2341,11 @@ int sja1105_static_config_reload(struct sja1105_private *priv,
 
        rc = sja1105_reload_cbs(priv);
 
+out:
        dsa_switch_for_each_available_port(dp, ds)
                if (dp->pl)
                        phylink_replay_link_end(dp->pl);
-out:
+
        mutex_unlock(&priv->mgmt_lock);
        mutex_unlock(&priv->fdb_lock);