Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] pinctrl: freescale: imx1: Fix device node leaks in imx1_pinctrl_dt_is_flat_functions()
@ 2026-08-21  5:08 Md Rabbani
  0 siblings, 0 replies; only message in thread
From: Md Rabbani @ 2026-08-21  5:08 UTC (permalink / raw)
  To: Frank Li, Fabio Estevam, Sascha Hauer, Linus Walleij
  Cc: Pengutronix Kernel Team, linux-gpio, imx, linux-arm-kernel,
	Md Rabbani

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>
---
 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



^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2026-08-21  5:08 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-21  5:08 [PATCH] pinctrl: freescale: imx1: Fix device node leaks in imx1_pinctrl_dt_is_flat_functions() Md Rabbani

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox