* [PATCH] pinctrl: meson: amlogic-a4: Fix device node reference leak in bank helpers
@ 2026-01-27 18:23 Felix Gu
2026-01-28 2:37 ` Xianwei Zhao
2026-02-03 0:29 ` Linus Walleij
0 siblings, 2 replies; 3+ messages in thread
From: Felix Gu @ 2026-01-27 18:23 UTC (permalink / raw)
To: Xianwei Zhao, Linus Walleij, Neil Armstrong, Kevin Hilman,
Jerome Brunet, Martin Blumenstingl
Cc: linux-amlogic, linux-gpio, linux-arm-kernel, linux-kernel,
Felix Gu
of_parse_phandle_with_fixed_args() increments the reference count of the
returned device node, so it must be explicitly released using
of_node_put() after use.
Fix the reference leak in aml_bank_pins() and aml_bank_number() by
adding the missing of_node_put() calls.
Fixes: 6e9be3abb78c ("pinctrl: Add driver support for Amlogic SoCs")
Signed-off-by: Felix Gu <ustc.gu@gmail.com>
---
drivers/pinctrl/meson/pinctrl-amlogic-a4.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/pinctrl/meson/pinctrl-amlogic-a4.c b/drivers/pinctrl/meson/pinctrl-amlogic-a4.c
index ded7b218e2ec..40542edd557e 100644
--- a/drivers/pinctrl/meson/pinctrl-amlogic-a4.c
+++ b/drivers/pinctrl/meson/pinctrl-amlogic-a4.c
@@ -725,8 +725,9 @@ static u32 aml_bank_pins(struct device_node *np)
if (of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3,
0, &of_args))
return 0;
- else
- return of_args.args[2];
+
+ of_node_put(of_args.np);
+ return of_args.args[2];
}
static int aml_bank_number(struct device_node *np)
@@ -736,8 +737,9 @@ static int aml_bank_number(struct device_node *np)
if (of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3,
0, &of_args))
return -EINVAL;
- else
- return of_args.args[1] >> 8;
+
+ of_node_put(of_args.np);
+ return of_args.args[1] >> 8;
}
static unsigned int aml_count_pins(struct device_node *np)
---
base-commit: 615aad0f61e0c7a898184a394dc895c610100d4f
change-id: 20260128-amlogic-0d08ef086c8b
Best regards,
--
Felix Gu <ustc.gu@gmail.com>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] pinctrl: meson: amlogic-a4: Fix device node reference leak in bank helpers
2026-01-27 18:23 [PATCH] pinctrl: meson: amlogic-a4: Fix device node reference leak in bank helpers Felix Gu
@ 2026-01-28 2:37 ` Xianwei Zhao
2026-02-03 0:29 ` Linus Walleij
1 sibling, 0 replies; 3+ messages in thread
From: Xianwei Zhao @ 2026-01-28 2:37 UTC (permalink / raw)
To: Felix Gu, Linus Walleij, Neil Armstrong, Kevin Hilman,
Jerome Brunet, Martin Blumenstingl
Cc: linux-amlogic, linux-gpio, linux-arm-kernel, linux-kernel
Reviewed-by: Xianwei Zhao <xianwei.zhao@amlogic.com>
On 2026/1/28 02:23, Felix Gu wrote:
> [You don't often get email from ustc.gu@gmail.com. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]
>
> [ EXTERNAL EMAIL ]
>
> of_parse_phandle_with_fixed_args() increments the reference count of the
> returned device node, so it must be explicitly released using
> of_node_put() after use.
>
> Fix the reference leak in aml_bank_pins() and aml_bank_number() by
> adding the missing of_node_put() calls.
>
> Fixes: 6e9be3abb78c ("pinctrl: Add driver support for Amlogic SoCs")
> Signed-off-by: Felix Gu <ustc.gu@gmail.com>
> ---
> drivers/pinctrl/meson/pinctrl-amlogic-a4.c | 10 ++++++----
> 1 file changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/pinctrl/meson/pinctrl-amlogic-a4.c b/drivers/pinctrl/meson/pinctrl-amlogic-a4.c
> index ded7b218e2ec..40542edd557e 100644
> --- a/drivers/pinctrl/meson/pinctrl-amlogic-a4.c
> +++ b/drivers/pinctrl/meson/pinctrl-amlogic-a4.c
> @@ -725,8 +725,9 @@ static u32 aml_bank_pins(struct device_node *np)
> if (of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3,
> 0, &of_args))
> return 0;
> - else
> - return of_args.args[2];
> +
> + of_node_put(of_args.np);
> + return of_args.args[2];
> }
>
> static int aml_bank_number(struct device_node *np)
> @@ -736,8 +737,9 @@ static int aml_bank_number(struct device_node *np)
> if (of_parse_phandle_with_fixed_args(np, "gpio-ranges", 3,
> 0, &of_args))
> return -EINVAL;
> - else
> - return of_args.args[1] >> 8;
> +
> + of_node_put(of_args.np);
> + return of_args.args[1] >> 8;
> }
>
> static unsigned int aml_count_pins(struct device_node *np)
>
> ---
> base-commit: 615aad0f61e0c7a898184a394dc895c610100d4f
> change-id: 20260128-amlogic-0d08ef086c8b
>
> Best regards,
> --
> Felix Gu <ustc.gu@gmail.com>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] pinctrl: meson: amlogic-a4: Fix device node reference leak in bank helpers
2026-01-27 18:23 [PATCH] pinctrl: meson: amlogic-a4: Fix device node reference leak in bank helpers Felix Gu
2026-01-28 2:37 ` Xianwei Zhao
@ 2026-02-03 0:29 ` Linus Walleij
1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2026-02-03 0:29 UTC (permalink / raw)
To: Felix Gu
Cc: Xianwei Zhao, Neil Armstrong, Kevin Hilman, Jerome Brunet,
Martin Blumenstingl, linux-amlogic, linux-gpio, linux-arm-kernel,
linux-kernel
On Tue, Jan 27, 2026 at 7:23 PM Felix Gu <ustc.gu@gmail.com> wrote:
> of_parse_phandle_with_fixed_args() increments the reference count of the
> returned device node, so it must be explicitly released using
> of_node_put() after use.
>
> Fix the reference leak in aml_bank_pins() and aml_bank_number() by
> adding the missing of_node_put() calls.
>
> Fixes: 6e9be3abb78c ("pinctrl: Add driver support for Amlogic SoCs")
> Signed-off-by: Felix Gu <ustc.gu@gmail.com>
Patch applied!
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-02-03 0:29 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-27 18:23 [PATCH] pinctrl: meson: amlogic-a4: Fix device node reference leak in bank helpers Felix Gu
2026-01-28 2:37 ` Xianwei Zhao
2026-02-03 0:29 ` Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox