Re: [PATCH] net: dsa: mt7530: fix regulator leak in mt7530_setup()

From: Xiangwu Lai

Date: Sun Nov 22 2026 - 21:30:53 EST


Hi,

On Sun, 22 Nov 2026 02:06:20 +0000, netdev-bot+sashiko wrote:
> Thank you for your contribution! Sashiko AI review found 3 potential
> issue(s) to consider.
>
> - [High] The fix is incomplete.
> - [Medium] The new err_powers/err_disable_core_pwr paths in
> mt7530_setup() disable core_pwr/io_pwr, but mt7530_remove() was not??> - [Low] This is speculative and depends on the hardware.

Thanks for the review, I verified all three findings against the code
and agree with them:

* High: Correct. The v2 error paths only covered mt7530_setup()
itself, while mt7530_setup_irq(), mt7530_setup_mdio() (both can also
return -EPROBE_DEFER), the SGMII PCS creation and the DSA core
setup steps can all fail afterwards with the regulators left
enabled, so the fix was indeed incomplete.

* Medium: Correct. In a multi-switch tree a switch can bind while its
ds->ops->setup has not run yet, and a later failing setup of that
switch is reported through the other switch's probe. The v2
unwinding would then have left the bound switch with an unbalanced
regulator_disable() in mt7530_remove().

* Low: Point taken. It is speculative for a software-only fix, and
mt7530_remove() already disables the regulators in the same order.

I have posted a v3 that adopts the ownership suggestion from the
review instead of unwinding manually:

[PATCH v3] net: dsa: mt7530: manage the core and io regulators with devm actions
https://lore.kernel.org/r/20261123022415.433-1-laixiangwu@xxxxxxxxxxxxxxxxxxxx

The enables now live in mt7530_probe(), each paired with a
devm_add_action_or_reset() that disables the regulator again, and the
explicit disables in mt7530_remove() are gone. This covers every
error path after the enables and keeps the enables and disables
balanced in all combinations of probe, setup and unbind.

For reference, the earlier versions of this fix:

v1: https://lore.kernel.org/r/20261118014114.1855-1-laixiangwu@xxxxxxxxxxxxxxxxxxxx
v2: https://lore.kernel.org/r/20261119060424.1476-1-laixiangwu@xxxxxxxxxxxxxxxxxxxx

pw-bot: cr

Best regards,
Xiangwu Lai