Article View: linux.kernel.netdev
Article #22415Re: [PATCH net 5/5] net: dsa: mt7530: disable regulators on mt753x_setup() failure
From: netdev-bot+sashiko
Date: Wed, 25 Nov 2026 09:27
Date: Wed, 25 Nov 2026 09:27
165 lines
14053 bytes
14053 bytes
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
Technical Details
Message-ID:
<179559883613.3135.7444939334405682827@kernel.org>Path:
mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-371183-linux-kernel-netdev=dewy.ruReferences:
<179550875790.4156.14185923394520188230@mail.zgclab.edu.cn>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!srv.newsdeef.eu!newsfeed.bofh.team!news.nntp4.net!nntp.xenet.de!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-371183-linux-kernel-netdev=dewy.ru From: netdev-bot+sashiko@kernel.org Newsgroups: linux.kernel.netdev Subject: Re: [PATCH net 5/5] net: dsa: mt7530: disable regulators on mt753x_setup() failure Date: Wed, 25 Nov 2026 09:27:16 +0000 Organization: Usenet Network Message-ID: <179559883613.3135.7444939334405682827@kernel.org> References: <179550875790.4156.14185923394520188230@mail.zgclab.edu.cn> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit Injection-Info: usenet.network; logging-data="167296"; mail-complaints-to="abuse@usenet.network" Cancel-Lock: sha1:7+SQLkV2r4YApDqMj3CIxtteU9M= sha256:qHX7ogULwWpfzNHlkT9n5OxcOx6u+qdqtqsl6liBDPs= sha1:7a6TvrW083RST/R/PyTQESsBKAg= sha256:Uf2Tb8hg93UxmNTnXRASxbJElx2nkJv5jp20nbTzvFg= List-ID: <netdev.vger.kernel.org> X-Mailpost-Empty-Hdrs: X-Spam-Level X-Received: from localhost (localhost [127.0.0.1]) by mail.dewy.ru (Postfix) with ESMTP id EE2D2125E4F; Wed, 25 Nov 2026 12:27:44 +0300 (MSK) X-Virus-Scanned: Debian amavisd-new at usenet.network X-Spam-Flag: NO X-Spam-Score: -3.4 X-Spam-Status: No, score=-3.4 tagged_above=-9999 required=6.31 tests=[DCC_REPUT_70_89=0.1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key) header.d=kernel.org X-Received: from mail.dewy.ru ([127.0.0.1]) by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3yp4ixdmPPns; Wed, 25 Nov 2026 12:27:41 +0300 (MSK) X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.234.253.10; helo=sea.lore.kernel.org; envelope-from=netdev+bounces-371183-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org X-Received: from sea.lore.kernel.org (sea.lore.kernel.org [172.234.253.10]) by mail.dewy.ru (Postfix) with ESMTPS id BF981125E4E; Wed, 25 Nov 2026 12:27:32 +0300 (MSK) X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sea.lore.kernel.org (Postfix) with ESMTP id 8E37842AC5; Wed, 25 Nov 2026 09:27:23 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795598843; b=kgSyalLEvgLJA/O6LR6xcpV0dyjRVFdD8Jb1iENCLFr/ih6+PqJO1B8THagry6wGj+jo tzq7ZBT9sY3yzisRUhRypg1OsreGc0aKe97ddWZ0EBfzlbVbCIIwbhsxBOi1n+ZgqMFKc cC1xWEoRT5qDoTCtjIPucDMrxLgjOvmndsxHfogNehZ/3SnRhyZT6CsWZtP3Mapg4EyqG FFd270Ig6AEvHlD90wU4LyYkbc9QSUyXndxiAOA+ECb6DijFMM9RzjfaRsdFmhsPluUbK x+sCePGgbyeI1v1WZMIeJ1EFOE7/YXEgUMyrsor0kd2ve2xmYj+OyHhBzQks11gSnfQ== X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795598843; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=4uoskY1EG7VAfNz08KwlvC9A41XTvME1bf3Oqeq2F30=; b=CpK9TUxBodu9xZAV6R2s+5D/E0eM6bc4YzVunG+Qs3kvBa7lWtXylnRfIOyTCeS9rTJQ jUKjfB+2LZ/pc8Dls60rexB0cw4pGAJOK9BxSCb+8RWJBPOe641qH373jmUAiBX54jY1n NrUPlna3Y05xZ8xdLAsGCpOMX35P9dhmPu2RH0/vI2HfVs/fgvllygBzEh/hJ0BoFu4a0 ApuU/n22nTkuHKNgv+7MFPyg4JrW8OxgCpuF/OxM7+DkgBiIZNj2q4nhCD5/Tf3jFwvoF lmKJYJA1nXfKx4aFmGvpJc9WwPLROuLqJeg5hMkS0tNvXAhAGLmgCiZSaCtCG4GYA9Q== X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=K9frEIov; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1 X-Received: from localhost.localdomain (localhost [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6553E606A321; Wed, 25 Nov 2026 09:27:23 +0000 (UTC) X-Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=K9frEIov X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1795598837; b=SWG+ndOj2EERXlpv2NbLAAKftVm2VK9ZqtVgyYoRiCQpicUVNHtgFIZH3B0QX5tB2gBd JDmeQkDyJkGsEJcZBk78m24oGBJWEAANT63KxJA6XJl2P92c/BUN00f8rLHNSheB2DQt1 FCQE+GZmN0zxH4HZ+4pjViBJ3ThF2q6SW2dcEcRVX6b2XLQeq25EuMxrbMvsGbIbToMZ+ pMrkbn5FPEmzLJXf9dRlXJGADMklW3ROmS/ZgM9LxPdWivNYuIzsnig5wEmMAoHn78ncJ ga7iIOWKJixdNFOflRGRuo3/tVM3Q82PGuecdC1cj6go4p89zJkNx8sJRw+OpVbaWkw== X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795598837; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=4uoskY1EG7VAfNz08KwlvC9A41XTvME1bf3Oqeq2F30=; b=pFjOL9QHxBHahxFA5xTtUh5TsYQopOOvCuSucuUrlb51YSdrNbtA6nmXr/LYBQCn+Xvj kD7xq7+IyfRmAyVqMww+WCzXyqLVJpOxOXkkaECwTiEIZ+XF/3fC+7eKwbsRA2egV2wAz jij4TtXGDw9QZOjzQFtGFGOzPSMT778xY7lI86LPyFUFGPWn1TKKdX1KoB4v0hVotJKZj sendYO4o9JXqlLmTWjAzrp+iWrcm7Af4Nk8nB4JnY9fSMvZzhsZvD4EIzjecHRfhc+OtT cBUYBBOkw1Qr8NG9EnUyN7MPYA0omc3tlC9Vqw6V9lhO0T2nehAmU0CHjtAVgjF6shQ== X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=K9frEIov; arc=none smtp.remote-ip=100.103.45.18 X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 85099606A681; Wed, 25 Nov 2026 09:27:17 +0000 (UTC) X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 85F951F000D4; Wed, 25 Nov 2026 09:27:16 +0000 (UTC) X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1795598837; bh=4uoskY1EG7VAfNz08KwlvC9A41XTvME1bf3Oqeq2F30=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=K9frEIovzSE8Eg54wK7g6G21X9W4+yTlJ4tZtlpzS4o9SeKmc7MkZeZYt+AUWnbpZ X/ckwT7EQs1JzCGsXhW6Fu2I2Bw5x2nnVCNo+D1m7tfsW2aKMq2m2S6hi4cpW9qLk7 ispD0DapAdic8h/rCUJAvf2qeUe2Pa5rWRZ+3159xjjnQlnj/OHh+4kIWbS3pTF0/0 Y/2NbPfQD+p2dRYespYbGDOKuFA656Wsu28a2PNpJNV+nEj7AkcZoqNu9mg4xh80dh DMOlv7Ze4Q69IemonLRKap99Vf6F510HIySvuoeD4s4qp7NpAhwFekcj1wf8SUqD// UFu/HEFKN2nnA== X-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 X-In-Reply-To: <179550875790.4156.14185923394520188230@mail.zgclab.edu.cn> X-sashiko-severity: High X-Mailing-List: netdev@vger.kernel.org X-List-Post: <mailto:netdev@vger.kernel.org> X-List-Help: <mailto:netdev+help@vger.kernel.org> X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org> X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org> X-List-Owner: <mailto:netdev+owner@vger.kernel.org> X-Precedence: list