Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.
Critical: 0 · High: 0 · Medium: 1 · Low: 0
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).
- [Medium] Two changes in mt753x_setup() (drivers/net/dsa/mt7530.c) now
power off the switch through sw_teardown while the GPIO controller is…
--
net: dsa: mt7530: disable regulators on mt753x_setup() failure
This patch sends every failure path in mt753x_setup() that runs after
sw_setup() to a shared error label. That label frees the mdio irq and
turns off the regulators. It also adds a per-variant sw_teardown()
callback, and for the MT7530 variants that callback calls
mt7530_disable_pwrs().
> diff --git a/drivers/net/dsa/mt7530.c b/drivers/net/dsa/mt7530.c
> index 1ae0ca2789690..32cf4a1ce2ace 100644
> --- a/drivers/net/dsa/mt7530.c
> +++ b/drivers/net/dsa/mt7530.c
[ ... ]
> @@ -3232,11 +3240,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)
> - goto err_disable_pwrs;
> + goto err_disable_pwrs;
[Severity: Medium]
Can these two new error paths leave the GPIO controller registered for a
switch that has no power?
By the time mt753x_setup() reaches mt7530_setup_irq(), sw_setup() has
already run. The last thing mt7530_setup() does is register the gpiochip:
drivers/net/dsa/mt7530.c:mt7530_setup() {
...
#ifdef CONFIG_GPIOLIB
if (of_property_read_bool(priv->dev->of_node, "gpio-controller")) {
ret = mt7530_setup_gpio(priv);
if (ret)
goto err_disable_pwrs;
}
...
}
mt7530_setup_gpio() uses devm_gpiochip_add_data(). The gpiochip is
therefore only removed when the switch device's devres unwinds.
mt7530_teardown() does not remove it.
On the mt7530_setup_mdio() failure path, the regmap IRQ chip registered
by devm_regmap_add_irq_chip_fwnode() in mt7530_setup_irq() is also still
live, together with its threaded handler.
mt753x_setup()
sw_setup() == mt7530_setup()
mt7530_setup_gpio()
devm_gpiochip_add_data()
mt7530_setup_irq() fails (for example -EPROBE_DEFER from of_irq_get())
goto err_disable_pwrs
mt7530_teardown()
mt7530_disable_pwrs()
regulator_disable(core_pwr / io_pwr)
The earlier patch in this series, "net: dsa: mt7530: register the GPIO
controller last in setup", moved GPIO registration to the end of
mt7530_setup(). The goal was that the controller would not stay
registered across a failed setup that turns off the regulators. Doesn't
this patch add new failure points after that registration? One of them
is the -EPROBE_DEFER case the commit message calls common.
In a single-switch tree this state only lasts until the failed probe's
devres unwinds.
In a multi-switch tree, dsa_tree_setup() runs from whichever member
probes last. An MT7530 whose own probe already returned 0 would then keep
its devm gpiochip, and possibly its regmap-irq handler, registered while
its core and io rails are off. Any GPIO get/set/direction call would then
do regmap accesses on an unpowered chip.
Before this patch, these paths left the rails on. Only ID_MT7530 is
affected, because mt7530_disable_pwrs() returns early for other ids.
The commit message describes sw_teardown() as "symmetric with
sw_setup()". mt7530_teardown() only undoes the regulator enable, though,
not the gpiochip that sw_setup() registers. Would it make sense either to
unregister the gpiochip (and the regmap irq chip) before cutting power
here, or to keep the regulators on for these paths until devres cleanup
runs?
>
> /* Initialise the PCS devices */
> for (i = 0; i < priv->ds->num_ports; i++) {
[ ... ]
> + return 0;
> +
> +err_free_irq:
> + if (priv->irq_domain)
> + mt7530_free_mdio_irq(priv);
> +err_disable_pwrs:
> + if (priv->info->sw_teardown)
> + priv->info->sw_teardown(ds);
> +
> return ret;
> }
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/1796…%40mail.zgclab.edu.cn