mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] pinctrl: renesas: rzt2h: Fix device node leak in rzt2h_gpio_register()
@ 2026-01-26 16:35 Felix Gu
  2026-01-27  8:43 ` Markus Elfring
  2026-01-28  7:55 ` Linus Walleij
  0 siblings, 2 replies; 5+ messages in thread
From: Felix Gu @ 2026-01-26 16:35 UTC (permalink / raw)
  To: Geert Uytterhoeven, Linus Walleij, Thierry Bultel, Lad Prabhakar
  Cc: linux-renesas-soc, linux-gpio, linux-kernel, Felix Gu

When calling of_parse_phandle_with_fixed_args(), the caller is responsible
for calling of_node_put() to release the device node reference.

In rzt2h_gpio_register(), the driver fails to call of_node_put() to
release the reference in of_args.np, which causes a memory leak.

Add the missing of_node_put() call to fix the leak.

Fixes: 34d4d093077a ("pinctrl: renesas: Add support for RZ/T2H")
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
---
 drivers/pinctrl/renesas/pinctrl-rzt2h.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/pinctrl/renesas/pinctrl-rzt2h.c b/drivers/pinctrl/renesas/pinctrl-rzt2h.c
index 9949108a35bb..5e0586d45cb7 100644
--- a/drivers/pinctrl/renesas/pinctrl-rzt2h.c
+++ b/drivers/pinctrl/renesas/pinctrl-rzt2h.c
@@ -833,6 +833,7 @@ static int rzt2h_gpio_register(struct rzt2h_pinctrl *pctrl)
 	if (ret)
 		return dev_err_probe(dev, ret, "Unable to parse gpio-ranges\n");
 
+	of_node_put(of_args.np);
 	if (of_args.args[0] != 0 || of_args.args[1] != 0 ||
 	    of_args.args[2] != pctrl->data->n_port_pins)
 		return dev_err_probe(dev, -EINVAL,

---
base-commit: ca3a02fda4da8e2c1cb6baee5d72352e9e2cfaea
change-id: 20260126-rzt2h-cbc9c1e35807

Best regards,
-- 
Felix Gu <ustc.gu@gmail.com>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] pinctrl: renesas: rzt2h: Fix device node leak in rzt2h_gpio_register()
  2026-01-26 16:35 [PATCH] pinctrl: renesas: rzt2h: Fix device node leak in rzt2h_gpio_register() Felix Gu
@ 2026-01-27  8:43 ` Markus Elfring
  2026-01-28  7:55 ` Linus Walleij
  1 sibling, 0 replies; 5+ messages in thread
From: Markus Elfring @ 2026-01-27  8:43 UTC (permalink / raw)
  To: Felix Gu, linux-renesas-soc, linux-gpio
  Cc: LKML, Geert Uytterhoeven, Jianhao Xu, Linus Walleij,
	Lad Prabhakar, Thierry Bultel, Zilin Guan

…
> In rzt2h_gpio_register(), the driver fails to call of_node_put() to
> release the reference in of_args.np, which causes a memory leak.
…

                                                      reference count?

* Were any source code analysis tools involved here?

* See also once more:
  https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/stable-kernel-rules.rst?h=v6.19-rc7#n34


Regards,
Markus

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] pinctrl: renesas: rzt2h: Fix device node leak in rzt2h_gpio_register()
  2026-01-26 16:35 [PATCH] pinctrl: renesas: rzt2h: Fix device node leak in rzt2h_gpio_register() Felix Gu
  2026-01-27  8:43 ` Markus Elfring
@ 2026-01-28  7:55 ` Linus Walleij
  2026-01-29  8:09   ` Geert Uytterhoeven
  1 sibling, 1 reply; 5+ messages in thread
From: Linus Walleij @ 2026-01-28  7:55 UTC (permalink / raw)
  To: Felix Gu
  Cc: Geert Uytterhoeven, Thierry Bultel, Lad Prabhakar,
	linux-renesas-soc, linux-gpio, linux-kernel

Hi Felix,

thanks for your patch!

On Mon, Jan 26, 2026 at 5:35 PM Felix Gu <ustc.gu@gmail.com> wrote:

> +       of_node_put(of_args.np);
>         if (of_args.args[0] != 0 || of_args.args[1] != 0 ||
>             of_args.args[2] != pctrl->data->n_port_pins)
>                 return dev_err_probe(dev, -EINVAL,

To me it's a bit odd to dereference .np and then use other parts of
the args the next line but maybe that works.

Geert will decide on the patch.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] pinctrl: renesas: rzt2h: Fix device node leak in rzt2h_gpio_register()
  2026-01-28  7:55 ` Linus Walleij
@ 2026-01-29  8:09   ` Geert Uytterhoeven
  2026-03-06 12:29     ` Geert Uytterhoeven
  0 siblings, 1 reply; 5+ messages in thread
From: Geert Uytterhoeven @ 2026-01-29  8:09 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Felix Gu, Geert Uytterhoeven, Thierry Bultel, Lad Prabhakar,
	linux-renesas-soc, linux-gpio, linux-kernel

Hi Linus,

On Wed, 28 Jan 2026 at 08:55, Linus Walleij <linusw@kernel.org> wrote:
> On Mon, Jan 26, 2026 at 5:35 PM Felix Gu <ustc.gu@gmail.com> wrote:
>
> > +       of_node_put(of_args.np);
> >         if (of_args.args[0] != 0 || of_args.args[1] != 0 ||
> >             of_args.args[2] != pctrl->data->n_port_pins)
> >                 return dev_err_probe(dev, -EINVAL,
>
> To me it's a bit odd to dereference .np and then use other parts of
> the args the next line but maybe that works.

The of_node pointer is not used at all. The code only needs to validate
the mapping numbers.

> Geert will decide on the patch.

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
i.e. will queue in renesas-pinctrl for v6.21.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] pinctrl: renesas: rzt2h: Fix device node leak in rzt2h_gpio_register()
  2026-01-29  8:09   ` Geert Uytterhoeven
@ 2026-03-06 12:29     ` Geert Uytterhoeven
  0 siblings, 0 replies; 5+ messages in thread
From: Geert Uytterhoeven @ 2026-03-06 12:29 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Felix Gu, Thierry Bultel, Lad Prabhakar, linux-renesas-soc,
	linux-gpio, linux-kernel

On Thu, 29 Jan 2026 at 09:09, Geert Uytterhoeven <geert@linux-m68k.org> wrote:
> On Wed, 28 Jan 2026 at 08:55, Linus Walleij <linusw@kernel.org> wrote:
> > On Mon, Jan 26, 2026 at 5:35 PM Felix Gu <ustc.gu@gmail.com> wrote:
> >
> > > +       of_node_put(of_args.np);
> > >         if (of_args.args[0] != 0 || of_args.args[1] != 0 ||
> > >             of_args.args[2] != pctrl->data->n_port_pins)
> > >                 return dev_err_probe(dev, -EINVAL,
> >
> > To me it's a bit odd to dereference .np and then use other parts of
> > the args the next line but maybe that works.
>
> The of_node pointer is not used at all. The code only needs to validate
> the mapping numbers.
>
> > Geert will decide on the patch.
>
> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
> i.e. will queue in renesas-pinctrl for v6.21.

Promoting to renesas-pinctrl-fixes for v7.0, as I have another fix.

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-03-06 12:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-01-26 16:35 [PATCH] pinctrl: renesas: rzt2h: Fix device node leak in rzt2h_gpio_register() Felix Gu
2026-01-27  8:43 ` Markus Elfring
2026-01-28  7:55 ` Linus Walleij
2026-01-29  8:09   ` Geert Uytterhoeven
2026-03-06 12:29     ` Geert Uytterhoeven

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®