* [PATCH] net: dsa: mt7530: fix regulator leak in mt7530_setup()
@ 2026-11-18 1:41 Xiangwu Lai
2026-11-18 1:42 ` netdev-bot+sinfo
0 siblings, 1 reply; 2+ messages in thread
From: Xiangwu Lai @ 2026-11-18 1:41 UTC (permalink / raw)
To: chester.a.unal, daniel, andrew, olteanv
Cc: sean.wang, netdev, linux-kernel, Xiangwu Lai
mt7530_setup() enables the "core" and "io" regulators of the MT7530,
but none of the error paths that follow (reset timeout, unsupported
chip ID, 20MHz XTAL, VLAN setup, PHY muxing, GPIO setup, FDB flush)
disables them again, leaving both regulators enabled after a failed
setup.
Add two error labels that disable what was enabled by then: the
io regulator failure path releases the already-enabled core
regulator, and all later failure paths disable both regulators.
MT7621 maps to the same sw_setup callback but skips the regulator
section entirely, so the cleanup at the common label is guarded
with a priv->id check to avoid unbalanced disables.
Fixes: b8f126a8d543 ("net-next: dsa: add dsa support for Mediatek MT7530 switch")
Signed-off-by: Xiangwu Lai <laixiangwu@cmss.chinamobile.com>
---
drivers/net/dsa/mt7530.c | 29 +++++++++++++++++++++--------
1 file changed, 21 insertions(+), 8 deletions(-)
diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
index 7781a63b4..2cf41282e 100644
--- a/drivers/net/dsa/mt7530.c
+++ b/drivers/net/dsa/mt7530.c
@@ -2425,7 +2425,7 @@ mt7530_setup(struct dsa_switch *ds)
if (ret < 0) {
dev_err(priv->dev, "Failed to enable io pwr: %d\n",
ret);
- return ret;
+ goto err_disable_core_pwr;
}
}
@@ -2447,20 +2447,22 @@ mt7530_setup(struct dsa_switch *ds)
val != 0, 20, 1000000);
if (ret < 0) {
dev_err(priv->dev, "reset timeout\n");
- return ret;
+ goto err_powers;
}
regmap_read(priv->regmap, MT7530_CREV, &id);
id = FIELD_GET(CHIP_NAME_MASK, id);
if (id != MT7530_ID) {
dev_err(priv->dev, "chip %x can't be supported\n", id);
- return -ENODEV;
+ ret = -ENODEV;
+ goto err_powers;
}
if ((val & MT7530_XTAL_MASK) == MT7530_XTAL_20MHZ) {
dev_err(priv->dev,
"MT7530 with a 20MHz XTAL is not supported!\n");
- return -EINVAL;
+ ret = -EINVAL;
+ goto err_powers;
}
/* Reset the switch through internal reset */
@@ -2527,7 +2529,7 @@ mt7530_setup(struct dsa_switch *ds)
/* Setup VLAN ID 0 for VLAN-unaware bridges */
ret = mt7530_setup_vlan0(priv);
if (ret)
- return ret;
+ goto err_powers;
/* Check for PHY muxing on port 5 */
if (dsa_is_unused_port(ds, 5)) {
@@ -2554,7 +2556,7 @@ mt7530_setup(struct dsa_switch *ds)
if (ret && ret != -ENODEV) {
of_node_put(mac_np);
of_node_put(phy_node);
- return ret;
+ goto err_powers;
}
id = of_mdio_parse_addr(ds->dev, phy_node);
if (id == 0)
@@ -2579,16 +2581,27 @@ mt7530_setup(struct dsa_switch *ds)
if (of_property_read_bool(priv->dev->of_node, "gpio-controller")) {
ret = mt7530_setup_gpio(priv);
if (ret)
- return ret;
+ goto err_powers;
}
#endif /* CONFIG_GPIOLIB */
/* Flush the FDB table */
ret = mt7530_fdb_cmd(priv, MT7530_FDB_FLUSH, NULL);
if (ret < 0)
- return ret;
+ goto err_powers;
return 0;
+
+err_disable_core_pwr:
+ regulator_disable(priv->core_pwr);
+ return ret;
+
+err_powers:
+ if (priv->id == ID_MT7530) {
+ regulator_disable(priv->io_pwr);
+ regulator_disable(priv->core_pwr);
+ }
+ return ret;
}
static int
--
2.50.1.windows.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] net: dsa: mt7530: fix regulator leak in mt7530_setup()
2026-11-18 1:41 [PATCH] net: dsa: mt7530: fix regulator leak in mt7530_setup() Xiangwu Lai
@ 2026-11-18 1:42 ` netdev-bot+sinfo
0 siblings, 0 replies; 2+ messages in thread
From: netdev-bot+sinfo @ 2026-11-18 1:42 UTC (permalink / raw)
To: Xiangwu Lai
Cc: chester.a.unal, daniel, andrew, olteanv, sean.wang, netdev,
linux-kernel
Hi!
This is an automated message. This series looks like a fix, but its
commit messages seem to be missing some information:
- How the issue was discovered, e.g. hit in production, hit during
development, syzbot report, manual code inspection, LLM or static
analysis tool scan.
- Whether the issue was actually triggered, or is only theoretical
(e.g. found by LLM and not proven at runtime). If it was triggered
please include the symptoms, like the stack trace or kernel messages.
Please do not repost the series just to address the above. Instead,
reply to this email with the missing information, so that reviewers
can take it into account.
*IMPORTANT*: If you do repost (for other reasons) - please include
the relevant info in the cover letter or commit messages.
--
The evaluation is done by an LLM so it may be wrong, if you think
that is the case please reply and explain.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-11-18 1:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-18 1:41 [PATCH] net: dsa: mt7530: fix regulator leak in mt7530_setup() Xiangwu Lai
2026-11-18 1:42 ` netdev-bot+sinfo
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox