* [PATCH] pinctrl: imx1: fix device_node leak in dt_is_flat_functions()
@ 2026-05-23 10:27 Felix Gu
2026-05-23 14:34 ` Frank Li
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Felix Gu @ 2026-05-23 10:27 UTC (permalink / raw)
To: Dong Aisheng, Fabio Estevam, Frank Li, Jacky Bai,
Pengutronix Kernel Team, NXP S32 Linux Team, Linus Walleij,
Sascha Hauer
Cc: linux-gpio, imx, linux-arm-kernel, linux-kernel, Felix Gu
for_each_child_of_node() holds a reference on the iterator node that
must be released on early return. imx1_pinctrl_dt_is_flat_functions()
has two early return paths inside the loop that skip this cleanup.
Replace both loops with the scoped variant so that the reference is
automatically dropped when the iterator goes out of scope.
Fixes: 63d2059cd665 ("pinctrl: imx1: Allow parsing DT without function nodes")
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
---
drivers/pinctrl/freescale/pinctrl-imx1-core.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/drivers/pinctrl/freescale/pinctrl-imx1-core.c b/drivers/pinctrl/freescale/pinctrl-imx1-core.c
index b7bd4ef9c0db..4a6bdaefa42f 100644
--- a/drivers/pinctrl/freescale/pinctrl-imx1-core.c
+++ b/drivers/pinctrl/freescale/pinctrl-imx1-core.c
@@ -547,14 +547,11 @@ static int imx1_pinctrl_parse_functions(struct device_node *np,
*/
static bool imx1_pinctrl_dt_is_flat_functions(struct device_node *np)
{
- struct device_node *function_np;
- struct device_node *pinctrl_np;
-
- for_each_child_of_node(np, function_np) {
+ for_each_child_of_node_scoped(np, function_np) {
if (of_property_present(function_np, "fsl,pins"))
return true;
- for_each_child_of_node(function_np, pinctrl_np) {
+ for_each_child_of_node_scoped(function_np, pinctrl_np) {
if (of_property_present(pinctrl_np, "fsl,pins"))
return false;
}
---
base-commit: c1ecb239fa3456529a32255359fc78b69eb9d847
change-id: 20260523-pinctrl-imx-b198f8391abf
Best regards,
--
Felix Gu <ustc.gu@gmail.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] pinctrl: imx1: fix device_node leak in dt_is_flat_functions()
2026-05-23 10:27 [PATCH] pinctrl: imx1: fix device_node leak in dt_is_flat_functions() Felix Gu
@ 2026-05-23 14:34 ` Frank Li
2026-05-26 9:46 ` Linus Walleij
2026-06-25 8:04 ` Linus Walleij
2 siblings, 0 replies; 4+ messages in thread
From: Frank Li @ 2026-05-23 14:34 UTC (permalink / raw)
To: Felix Gu
Cc: Dong Aisheng, Fabio Estevam, Jacky Bai, Pengutronix Kernel Team,
NXP S32 Linux Team, Linus Walleij, Sascha Hauer, linux-gpio, imx,
linux-arm-kernel, linux-kernel
On Sat, May 23, 2026 at 06:27:05PM +0800, Felix Gu wrote:
> for_each_child_of_node() holds a reference on the iterator node that
> must be released on early return. imx1_pinctrl_dt_is_flat_functions()
> has two early return paths inside the loop that skip this cleanup.
>
> Replace both loops with the scoped variant so that the reference is
> automatically dropped when the iterator goes out of scope.
>
> Fixes: 63d2059cd665 ("pinctrl: imx1: Allow parsing DT without function nodes")
> Signed-off-by: Felix Gu <ustc.gu@gmail.com>
> ---
Thank you for fix it.
Reviewed-by: Frank Li <Frank.Li@nxp.com>
> drivers/pinctrl/freescale/pinctrl-imx1-core.c | 7 ++-----
> 1 file changed, 2 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/pinctrl/freescale/pinctrl-imx1-core.c b/drivers/pinctrl/freescale/pinctrl-imx1-core.c
> index b7bd4ef9c0db..4a6bdaefa42f 100644
> --- a/drivers/pinctrl/freescale/pinctrl-imx1-core.c
> +++ b/drivers/pinctrl/freescale/pinctrl-imx1-core.c
> @@ -547,14 +547,11 @@ static int imx1_pinctrl_parse_functions(struct device_node *np,
> */
> static bool imx1_pinctrl_dt_is_flat_functions(struct device_node *np)
> {
> - struct device_node *function_np;
> - struct device_node *pinctrl_np;
> -
> - for_each_child_of_node(np, function_np) {
> + for_each_child_of_node_scoped(np, function_np) {
> if (of_property_present(function_np, "fsl,pins"))
> return true;
>
> - for_each_child_of_node(function_np, pinctrl_np) {
> + for_each_child_of_node_scoped(function_np, pinctrl_np) {
> if (of_property_present(pinctrl_np, "fsl,pins"))
> return false;
> }
>
> ---
> base-commit: c1ecb239fa3456529a32255359fc78b69eb9d847
> change-id: 20260523-pinctrl-imx-b198f8391abf
>
> Best regards,
> --
> Felix Gu <ustc.gu@gmail.com>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] pinctrl: imx1: fix device_node leak in dt_is_flat_functions()
2026-05-23 10:27 [PATCH] pinctrl: imx1: fix device_node leak in dt_is_flat_functions() Felix Gu
2026-05-23 14:34 ` Frank Li
@ 2026-05-26 9:46 ` Linus Walleij
2026-06-25 8:04 ` Linus Walleij
2 siblings, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2026-05-26 9:46 UTC (permalink / raw)
To: Felix Gu
Cc: Dong Aisheng, Fabio Estevam, Frank Li, Jacky Bai,
Pengutronix Kernel Team, NXP S32 Linux Team, Sascha Hauer,
linux-gpio, imx, linux-arm-kernel, linux-kernel
On Sat, May 23, 2026 at 12:27 PM Felix Gu <ustc.gu@gmail.com> wrote:
> for_each_child_of_node() holds a reference on the iterator node that
> must be released on early return. imx1_pinctrl_dt_is_flat_functions()
> has two early return paths inside the loop that skip this cleanup.
>
> Replace both loops with the scoped variant so that the reference is
> automatically dropped when the iterator goes out of scope.
>
> Fixes: 63d2059cd665 ("pinctrl: imx1: Allow parsing DT without function nodes")
> Signed-off-by: Felix Gu <ustc.gu@gmail.com>
So what we got here is a non-critical patch on top of something that was
critical and was merged as fixes. (A minor memory leak is not critical
and not -rc material.)
Linus (the big penguin) has been annoyed of too many noncritical
patches going in as fixes recently so can you please resend this after
the next merge window? (I will try to remember the patch as well.)
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] pinctrl: imx1: fix device_node leak in dt_is_flat_functions()
2026-05-23 10:27 [PATCH] pinctrl: imx1: fix device_node leak in dt_is_flat_functions() Felix Gu
2026-05-23 14:34 ` Frank Li
2026-05-26 9:46 ` Linus Walleij
@ 2026-06-25 8:04 ` Linus Walleij
2 siblings, 0 replies; 4+ messages in thread
From: Linus Walleij @ 2026-06-25 8:04 UTC (permalink / raw)
To: Felix Gu
Cc: Dong Aisheng, Fabio Estevam, Frank Li, Jacky Bai,
Pengutronix Kernel Team, NXP S32 Linux Team, Sascha Hauer,
linux-gpio, imx, linux-arm-kernel, linux-kernel
On Sat, May 23, 2026 at 12:27 PM Felix Gu <ustc.gu@gmail.com> wrote:
> for_each_child_of_node() holds a reference on the iterator node that
> must be released on early return. imx1_pinctrl_dt_is_flat_functions()
> has two early return paths inside the loop that skip this cleanup.
>
> Replace both loops with the scoped variant so that the reference is
> automatically dropped when the iterator goes out of scope.
>
> Fixes: 63d2059cd665 ("pinctrl: imx1: Allow parsing DT without function nodes")
> Signed-off-by: Felix Gu <ustc.gu@gmail.com>
Patch applied for v7.3!
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-06-25 8:04 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-05-23 10:27 [PATCH] pinctrl: imx1: fix device_node leak in dt_is_flat_functions() Felix Gu
2026-05-23 14:34 ` Frank Li
2026-05-26 9:46 ` Linus Walleij
2026-06-25 8:04 ` Linus Walleij
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®