From: netdev-bot+sashiko@kernel.org
To: wanghr2026@mail.zgclab.edu.cn
Cc: chester.a.unal@arinc9.com, daniel@makrotopia.org, andrew@lunn.ch,
olteanv@gmail.com, davem@davemloft.net, edumazet@kernel.org,
kuba@kernel.org, pabeni@redhat.com, matthias.bgg@gmail.com,
angelogioacchino.delregno@collabora.com, netdev@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net 5/5] net: dsa: mt7530: disable regulators on mt753x_setup() failure
Date: Wed, 25 Nov 2026 09:27:16 +0000 [thread overview]
Message-ID: <179559883613.3135.7444939334405682827@kernel.org> (raw)
In-Reply-To: <179550875790.4156.14185923394520188230@mail.zgclab.edu.cn>
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 1 (1) · Medium: 0 · Low: 1
If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).
- [High] In mt753x_setup() (drivers/net/dsa/mt7530.c), the new error
paths turn off the MT7530 core/io regulators while devm still keeps…
- [Low] net: dsa: mt7530: inaccurate Fixes tag for mt753x_setup()
regulator leak
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but it sits on the
failure path the patch reworks.
--
net: dsa: mt7530: disable regulators on mt753x_setup() failure
This patch sends the failure paths in mt753x_setup() that come after
sw_setup() to a shared error label. That label disables the MT7530 core
and io regulators. The mdio irq teardown after a create_sgmii() failure
moves into the same error path.
> diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
> index 1ac4ac1a05664..963d145341759 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;
[Severity: Low]
Is b8f126a8d543 the right commit for the Fixes tag?
In b8f126a8d543, mt7530_switch_ops.setup pointed straight at
mt7530_setup(). There was no mt753x_setup() wrapper and nothing ran
after sw_setup(). The wrapper came with 88bdef8be9f6 ("net: dsa:
mt7530: Extend device data ready for adding a new hardware"), and
at that point it only did:
return priv->info->sw_setup(ds);
This patch now unwinds the fallible steps after sw_setup(), which are
mt7530_setup_irq() and mt7530_setup_mdio(). Those steps seem to have
come in with ba751e28d442 ("net: dsa: mt7530: add interrupt support").
That commit is where the early returns that leave the regulators on
were added.
With the Fixes tag pointing at the initial driver, the stable tooling
will try to apply this to kernels that have neither mt753x_setup() nor
these failure paths. Should the tag be this instead?
Fixes: ba751e28d442 ("net: dsa: mt7530: add interrupt support")
[Severity: High]
Can these new gotos power off the switch while things that need power
are still registered?
When mt753x_setup() reaches this point, mt7530_setup() has already
returned 0. If the DT node has "gpio-controller", the GPIO controller is
already published:
mt7530_setup()
mt7530_setup_gpio()
return devm_gpiochip_add_data(dev, gc, priv);
Suppose mt7530_setup_irq() then fails, for example with -EPROBE_DEFER
from of_irq_get(). The commit message calls this the common case. In
that case mt7530_disable_pwrs() turns off the rails and the gpiochip
stays registered.
If mt7530_setup_mdio() fails instead, the regmap-irq chip from
devm_regmap_add_irq_chip_fwnode() in mt7530_setup_irq() also stays
registered. Its parent IRQ stays requested and TOP_SIG_CTRL_NORMAL stays
set.
Nothing on these paths unregisters them. Only devres unwinding removes
them:
- With a single switch, devres unwinds after dsa_register_switch() fails
and probe returns.
- In a multi-switch tree, this switch's probe may already have returned
0 and the tree setup runs from a sibling's probe. Then devres never
unwinds here, and the switch stays bound against unpowered hardware.
The earlier patch in this series, "net: dsa: mt7530: register the GPIO
controller last in setup", says:
This becomes important in the next patch, where
the failure paths disable the regulators and return an error, so the
controller must not be registered across a failed setup.
Doesn't this patch make that state reachable again on the
mt7530_setup_irq() and mt7530_setup_mdio() failure paths? Only ID_MT7530
is affected, because mt7530_disable_pwrs() returns early for the other
variants.
Could the regulator-dependent registrations (the gpiochip, and ideally
the irq chip and MDIO bus) happen after every fallible step in
mt753x_setup()? Alternatively, could they be undone explicitly before
mt7530_disable_pwrs() is called?
[ ... ]
> @@ -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;
[Severity: High]
This is a pre-existing issue, but it sits on the failure path this patch
reworks. Can a failed create_sgmii() leave priv->ports[5].sgmii_pcs
dangling, and then have it freed a second time?
Take mt7531_create_sgmii() in drivers/net/dsa/mt7530-mdio.c with
p5_sgmii set, where port5 succeeds and port6 fails:
if (ret && i)
mtk_pcs_lynxi_destroy(priv->ports[5].sgmii_pcs);
return ret;
This frees the port5 PCS but does not clear the pointer. Port6 can fail
in devm_kzalloc_obj(), in devm_regmap_init(), or when
mtk_pcs_lynxi_create() returns NULL.
With a single switch, probe fails and devres frees priv.
In a multi-switch tree, the MT7531 can register before the tree is
complete, so its probe returns 0. mt753x_setup() then runs later from a
sibling's probe via dsa_tree_setup()->dsa_switch_setup(). If
create_sgmii() fails there, the MT7531 stays bound with the stale
pointer. On a later unbind this runs:
mt7530_remove()
for (i = 0; i < 2; ++i)
mtk_pcs_lynxi_destroy(priv->ports[5 + i].sgmii_pcs);
Is the port5 PCS kfree()d a second time here? Setting
priv->ports[5].sgmii_pcs = NULL after the destroy in
mt7531_create_sgmii() would avoid it.
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/179550875789.4156.361477684651496992%40mail.zgclab.edu.cn
next prev parent reply other threads:[~2026-11-25 9:27 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 8:25 [PATCH net 0/5] net: dsa: mt7530: fix regulator disable on teardown and error paths Haoran Wang
2026-11-24 8:25 ` [PATCH net 2/5] net: dsa: mt7530: factor out mt7530_disable_pwrs() Haoran Wang
2026-11-24 18:35 ` Andrew Lunn
2026-11-24 8:25 ` [PATCH net 1/5] net: dsa: mt7530: disable regulators on switch teardown Haoran Wang
2026-11-24 18:31 ` Andrew Lunn
2026-11-25 9:27 ` netdev-bot+sashiko
2026-11-24 8:25 ` [PATCH net 5/5] net: dsa: mt7530: disable regulators on mt753x_setup() failure Haoran Wang
2026-11-24 18:50 ` Andrew Lunn
2026-11-25 9:27 ` netdev-bot+sashiko [this message]
2026-11-24 8:25 ` [PATCH net 4/5] net: dsa: mt7530: disable regulators on setup failure Haoran Wang
2026-11-24 18:42 ` Andrew Lunn
2026-11-24 8:25 ` [PATCH net 3/5] net: dsa: mt7530: register the GPIO controller last in setup Haoran Wang
2026-11-24 18:38 ` Andrew Lunn
2026-11-25 9:27 ` netdev-bot+sashiko
2026-11-24 8:33 ` [PATCH net 0/5] net: dsa: mt7530: fix regulator disable on teardown and error paths netdev-bot+sinfo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179559883613.3135.7444939334405682827@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew@lunn.ch \
--cc=angelogioacchino.delregno@collabora.com \
--cc=chester.a.unal@arinc9.com \
--cc=daniel@makrotopia.org \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=wanghr2026@mail.zgclab.edu.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox