Skip to contentSkip to conversation

pinctrl: meson: amlogic-a4: Fix device node reference leak in bank helpers

PATCH In review Felix Gu 3 participants 3 messages Jan 27 – Feb 3

Subsystems (4)
lore
Share & tools
lore

Felix Gu

author
#0 lore raw

PATCH 1/1 pinctrl: meson: amlogic-a4: Fix device node reference leak in bank helpers

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")
---
 drivers/pinctrl/meson/pinctrl-amlogic-a4.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/pinctrl/meson/pinctrl-amlogic-a4.c +6 -4
index ded7b218e2ec..40542edd557e 100644
@@ -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,

Signature · 1 line
Felix Gu <[email protected]>
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 54 lines · Felix Gu

[You don't often get email from [email protected]. 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")
---
  drivers/pinctrl/meson/pinctrl-amlogic-a4.c | 10 ++++++----
  1 file changed, 6 insertions(+), 4 deletions(-)
drivers/pinctrl/meson/pinctrl-amlogic-a4.c +6 -5
index ded7b218e2ec..40542edd557e 100644
@@ -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 <[email protected]>

maintainer
#2 lore raw
In reply to Felix Gu
Quoted 9 lines · 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")

Patch applied!

Yours,
Linus Walleij