Linux GPIO subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Fabio Forni" <development@redaril.me>
Cc: linux-gpio@vger.kernel.org
Subject: Re: [PATCH v4 2/3] mux: convert to use fwnode interface
Date: Thu, 08 Oct 2026 20:16:33 +0000	[thread overview]
Message-ID: <sashiko-outbox-164567@kernel.org> (raw)
In-Reply-To: <20261008-mux_fwnode-v4-2-ba3330e44b2a@redaril.me>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] pinctrl: memory leak in dt_node_to_map on probe deferral
--

commit a66771846f5e6a77740838d742398ffebadf6b60
Author: Fabio Forni <development@redaril.me>

mux: convert to use fwnode interface

This commit converts the mux subsystem to use the fwnode interface
instead of device nodes, as firmware node is a more common abstraction.

> diff --git a/drivers/pinctrl/pinctrl-generic-mux.c b/drivers/pinctrl/pinctrl-generic-mux.c
> index 202b72351efb7..6d5b6100c5ca2 100644
> --- a/drivers/pinctrl/pinctrl-generic-mux.c
> +++ b/drivers/pinctrl/pinctrl-generic-mux.c
[ ... ]
> @@ -50,7 +50,9 @@ mux_pinmux_dt_node_to_map(struct pinctrl_dev *pctldev,
>  	if (!group_names)
>  		return -ENOMEM;
>  
> -	function->mux_state = devm_mux_state_get_from_np(pctldev->dev, NULL, np_config);
> +	function->mux_state = devm_mux_state_get_from_fwnode(pctldev->dev,
> +							     NULL,
> +							     of_fwnode_handle(np_config));

[Severity: Medium]
Will this leak memory if the consumer device defers probing?

The mux_pinmux_dt_node_to_map() function is called by the pinctrl core each
time a consumer parses its DT mappings. It allocates devm resources explicitly
bound to pctldev->dev (the pinctrl provider device), including the mux_state
allocated here, as well as the function and group_names allocated earlier in
the same function:

	function = devm_kzalloc(pctldev->dev, sizeof(*function), GFP_KERNEL);
	if (!function)
		return -ENOMEM;

	group_names = devm_kcalloc(pctldev->dev, 1, sizeof(*group_names), GFP_KERNEL);
	if (!group_names)
		return -ENOMEM;

If the consumer device's probe later returns -EPROBE_DEFER, the consumer's
pinctrl mappings are freed, but these devm allocations remain permanently bound
to the provider device. 

When the consumer reprobes, it triggers this function again, returning the
existing selector from pinmux_generic_add_function() and completely leaking
the newly allocated devm resources on the provider's devres list. Repeated
probe deferrals can cause an unbounded memory leak.

Should these allocations be tied to the consumer device instead, or explicitly
freed when the map is released?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261008-mux_fwnode-v4-0-ba3330e44b2a@redaril.me?part=2

  reply	other threads:[~2026-10-08 20:16 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-08 20:06 [PATCH v4 0/3] Migrate the multiplexer subsystem to fwnode Fabio Forni via B4 Relay
2026-10-08 20:06 ` [PATCH v4 1/3] mux: Avoid use-after-free of args.np in mux_get() Fabio Forni via B4 Relay
2026-10-08 20:06 ` [PATCH v4 2/3] mux: convert to use fwnode interface Fabio Forni via B4 Relay
2026-10-08 20:16   ` sashiko-bot [this message]
2026-10-08 20:06 ` [PATCH v4 3/3] mux: Document mux_chip_find_by_fwnode() Fabio Forni via B4 Relay

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=sashiko-outbox-164567@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=development@redaril.me \
    --cc=linux-gpio@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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