Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
From: Frank Li <Frank.li@oss.nxp.com>
To: Md Rabbani <rabbanyhmm@gmail.com>
Cc: Frank Li <Frank.Li@nxp.com>, Fabio Estevam <festevam@gmail.com>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Linus Walleij <linusw@kernel.org>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	linux-gpio@vger.kernel.org, imx@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH] pinctrl: freescale: imx1: Fix device node leaks in imx1_pinctrl_dt_is_flat_functions()
Date: Fri, 21 Aug 2026 10:00:03 -0500	[thread overview]
Message-ID: <aohn8ybsXRBcbw5t@SMW015318> (raw)
In-Reply-To: <20260821050813.739-1-rabbanyhmm@gmail.com>

On Fri, Aug 21, 2026 at 11:08:13AM +0600, Md Rabbani wrote:
> [You don't often get email from rabbanyhmm@gmail.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> imx1_pinctrl_dt_is_flat_functions() uses for_each_child_of_node() to
> iterate over child and grandchild nodes. When the function returns
> early upon finding an "fsl,pins" property, it does not release the
> acquired device_node references, leaking their reference counts.
>
> Switch to for_each_child_of_node_scoped() to automatically drop the
> node references on early return and loop exit, matching the pattern used
> in pinctrl-imx.c and elsewhere in this driver.
>
> Signed-off-by: Md Rabbani <rabbanyhmm@gmail.com>
> ---

Manush Prajwal already post the same patch

https://lore.kernel.org/imx/20260814190527.969-1-manushprajwal555@gmail.com/

Frank
>  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 b7bd4ef9c0..4a6bdaefa4 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;
>                 }
> --
> 2.55.0.windows.3
>
>

      reply	other threads:[~2026-08-21 15:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-21  5:08 [PATCH] pinctrl: freescale: imx1: Fix device node leaks in imx1_pinctrl_dt_is_flat_functions() Md Rabbani
2026-08-21 15:00 ` Frank Li [this message]

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=aohn8ybsXRBcbw5t@SMW015318 \
    --to=frank.li@oss.nxp.com \
    --cc=Frank.Li@nxp.com \
    --cc=festevam@gmail.com \
    --cc=imx@lists.linux.dev \
    --cc=kernel@pengutronix.de \
    --cc=linusw@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=rabbanyhmm@gmail.com \
    --cc=s.hauer@pengutronix.de \
    /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