From: Chancel Liu <chancel.liu@oss.nxp.com>
To: Frank Li <Frank.li@oss.nxp.com>
Cc: linusw@kernel.org, Frank.Li@nxp.com, linux-gpio@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] pinctrl: pinctrl-generic-mux: Fix provider resource leak on re-parse
Date: Thu, 17 Sep 2026 10:29:49 +0800 [thread overview]
Message-ID: <a63033c5-e4c2-4e80-b1e4-fd8423f463a5@oss.nxp.com> (raw)
In-Reply-To: <aqr6u62EOwjXZSSx@lizhi-Precision-Tower-5810>
>> @@ -38,39 +36,73 @@ mux_pinmux_dt_node_to_map(struct pinctrl_dev *pctldev,
>> struct pinctrl_map **maps, unsigned int *num_maps)
>> {
>> unsigned int num_reserved_maps = 0;
>> - struct mux_pin_function *function;
>> - const char **group_names;
>> int ret;
>>
>> - 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;
>
>
> devm alloc is quite popular under drivers/pinctrl
>
> airoha/pinctrl-airoha.c dt_node_to_map devm_kzalloc, devm_pinctrl_register_and_init
> meson/pinctrl-amlogic-a4.c dt_node_to_map devm_kcalloc
> pinctrl-at91.c at91_dt_node_to_map devm_kcalloc, devm_kfree
> pinctrl-axp209.c dt_node_to_map devm_kcalloc
> pinctrl-generic-mux.c mux_pinmux_dt_node_to_map devm_kcalloc, devm_kzalloc, devm_mux_state_get_from_np
> pinctrl-generic.c pinctrl_generic_dt_node_to_map devm_kcalloc
> pinctrl-single.c pcs_dt_node_to_map devm_kcalloc, devm_kfree, devm_kzalloc
> pinctrl-st.c st_pctl_dt_node_to_map devm_kcalloc, devm_kfree
> pinctrl-th1520.c th1520_pinctrl_dt_node_to_map devm_kasprintf, devm_kcalloc
> pinctrl-tps6594.c dt_node_to_map devm_gpio_regmap_register, devm_kzalloc, devm_pinctrl_register
> renesas/pinctrl-rza1.c rza1_dt_node_to_map devm_kcalloc, devm_kzalloc
> renesas/pinctrl-rza2.c rza2_dt_node_to_map devm_kcalloc, devm_kzalloc
> sophgo/pinctrl-sophgo-common.c sophgo_pctrl_dt_node_to_map devm_kasprintf, devm_kcalloc
> starfive/pinctrl-starfive-jh7100.c starfive_dt_node_to_map devm_kasprintf, devm_kcalloc
> starfive/pinctrl-starfive-jh7110.c jh7110_dt_node_to_map devm_kasprintf, devm_kcalloc
> sunplus/sppctl.c dt_node_to_map devm_kcalloc
> ti/pinctrl-ti-iodelay.c ti_iodelay_dt_node_to_map devm_kcalloc, devm_kfree, devm_kzalloc
>
> does all have similar problem? I suspect this when do this patch, but I
> have not tracked these life cycle.
>
> Frank
>
Not all, but many do. devm_* in .dt_node_to_map() only leaks when the
allocation is bound to the provider dev and isn't reclaimed by
.dt_free_map(). So it accumulates on every re-parse.
Here's the calling:
really_probe()
└─ pinctrl_bind_pins(dev)
└─ devm_pinctrl_get(dev)
└─ create_pinctrl()
└─ pinctrl_dt_to_map(p, pctldev)
└─ dt_to_map_one_config()
└─ ops->dt_node_to_map()
Every deferred-probe retry and every re-bind re-invokes .dt_node_to_map().
Regards,
Chancel Liu
next prev parent reply other threads:[~2026-09-17 2:30 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-16 3:04 Chancel Liu
2026-09-16 20:23 ` Frank Li
2026-09-17 2:29 ` Chancel Liu [this message]
2026-09-17 21:02 ` Frank Li
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=a63033c5-e4c2-4e80-b1e4-fd8423f463a5@oss.nxp.com \
--to=chancel.liu@oss.nxp.com \
--cc=Frank.Li@nxp.com \
--cc=Frank.li@oss.nxp.com \
--cc=linusw@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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
all inboxes | Powered by JetHome®