[PATCH net 5/5] net: dsa: mt7530: disable regulators on mt753x_setup() failure

Haoran Wang wanghr2026 at mail.zgclab.edu.cn
Tue Nov 24 00:25:57 PST 2026


mt753x_setup() calls the per-variant sw_setup() (mt7530_setup() for the
MT7530), which enables the regulators, but the steps that follow returned
on error without disabling them. The common case is mt7530_setup_irq()
returning -EPROBE_DEFER, which leaves the rails on and re-enables them on
every re-probe.

Route all failure paths after sw_setup() to a shared error label that
disables the regulators, and move the mdio irq teardown there instead of
handling it inline.

Fixes: b8f126a8d543 ("net-next: dsa: add dsa support for Mediatek MT7530 switch")
Signed-off-by: Haoran Wang <wanghr2026 at mail.zgclab.edu.cn>
---
 drivers/net/dsa/mt7530.c | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
index 1ac4ac1a0566..963d14534175 100644
--- a/drivers/net/dsa/mt7530.c
+++ b/drivers/net/dsa/mt7530.c
@@ -3223,11 +3223,11 @@ mt753x_setup(struct dsa_switch *ds)
 
 	ret = mt7530_setup_irq(priv);
 	if (ret)
-		return ret;
+		goto err_disable_pwrs;
 
 	ret = mt7530_setup_mdio(priv);
 	if (ret)
-		return ret;
+		goto err_disable_pwrs;
 
 	/* Initialise the PCS devices */
 	for (i = 0; i < priv->ds->num_ports; i++) {
@@ -3239,15 +3239,23 @@ mt753x_setup(struct dsa_switch *ds)
 	if (priv->create_sgmii)
 		ret = priv->create_sgmii(priv);
 
-	if (ret && priv->irq_domain)
-		mt7530_free_mdio_irq(priv);
+	if (ret)
+		goto err_free_irq;
 
-	if (!ret && priv->bus) {
+	if (priv->bus) {
 		mt7530_stats_refresh(priv);
 		schedule_delayed_work(&priv->stats_work,
 				      MT7530_STATS_POLL_INTERVAL);
 	}
 
+	return 0;
+
+err_free_irq:
+	if (priv->irq_domain)
+		mt7530_free_mdio_irq(priv);
+err_disable_pwrs:
+	mt7530_disable_pwrs(priv);
+
 	return ret;
 }
 




More information about the linux-arm-kernel mailing list