[PATCH v2] pinctrl: stm32: Fix reset control leak in stm32_pctl_probe() error paths

Xiangwu Lai laixiangwu at cmss.chinamobile.com
Wed Nov 18 22:09:24 PST 2026


Hi Linus,

thanks for taking a look.  For the record, this is about "[PATCH v2]
pinctrl: stm32: Fix reset control leak in stm32_pctl_probe() error
paths":

https://lore.kernel.org/all/20261110083253.1525-1-laixiangwu@cmss.chinamobile.com/

On Wed, Nov 18, 2026 at 10:09:40PM +0100, Linus Walleij wrote:
> Fix your email address in .gitconfig please so you don't use
> your login name as name.

Sorry about that.  The email address is unchanged, what was wrong is
that git picked my login handle up as the user name; the .gitconfig
name is set to "Xiangwu Lai" now, and the patch was already resent
with the corrected author and sign-off before your reply arrived - it
is identical to v2 otherwise:

[PATCH v3] pinctrl: stm32: Fix reset control leak in stm32_pctl_probe() error paths
https://lore.kernel.org/all/20261116031043.502-1-laixiangwu@cmss.chinamobile.com/

On Wed, Nov 18, 2026 at 10:08:09PM +0100, Linus Walleij wrote:
> Looks like a bulky fix, what about just stop using
> of_reset_control_get_exclusive()
> and use devm_reset_control_get_exclusive(&pdev->dev, ..) hmm?

The managed getter is unfortunately not a drop-in replacement here:
the reset phandles live in the per-bank child nodes, while
devm_reset_control_get_exclusive() resolves the "resets" property
from dev_fwnode(&pdev->dev), that is the pinctrl node itself.  The
driver fetches one reset line per GPIO bank from each child:

	bank->rstc = of_reset_control_get_exclusive(np, NULL);

with np = to_of_node(child).  The reset core only provides devm
variants that take a struct device *; there is no devm getter
parameterized by a device_node/fwnode, which is what the per-bank
lookup would need.

If you prefer the managed form, the equivalent that keeps the
child-node lookup would be to register the put as a devm action after
each successful get:

	static void stm32_pctl_put_reset_control(void *data)
	{
		reset_control_put(data);
	}

	bank->rstc = of_reset_control_get_exclusive(np, NULL);
	if (PTR_ERR(bank->rstc) == -EPROBE_DEFER) {
		...
		return -EPROBE_DEFER;
	}

	ret = devm_add_action_or_reset(dev, stm32_pctl_put_reset_control,
				       bank->rstc);

which turns all the error paths back into plain returns - devres
releases the rstcs acquired so far - and removes the goto
err_put_rstcs wiring from v3.  On success the semantics stay as they
are: the rstcs are held for the lifetime of the device (the driver
has no .remove) and are still in use, stm32_gpiolib_register_bank()
deasserts them.  phy-qcom-qmp-pcie-msm8996.c uses the same
combination for the same reason, a reset phandle living in a
sub-node.

Philipp, does this look sane from the reset core point of view, or
would a devm getter that takes a fwnode be something acceptable in
the core?

I can respin a v4 with the devm action conversion on top of v3, or
keep the explicit unwind of v3 - let me know which form you prefer.

Best regards,
Xiangwu Lai





More information about the linux-arm-kernel mailing list