summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFelix Gu <ustc.gu@gmail.com>2026-05-23 18:27:05 +0800
committerLinus Walleij <linusw@kernel.org>2026-06-30 10:57:50 +0200
commit7b1272d02e65d2d4aeffb0d85b290a8753d24c12 (patch)
tree74b726c268fb0fa76295da1afc4306a41e4e6058
parentdc59e4fea9d83f03bad6bddf3fa2e52491777482 (diff)
downloadlinux-stable-7b1272d02e65d2d4aeffb0d85b290a8753d24c12.tar.gz
linux-stable-7b1272d02e65d2d4aeffb0d85b290a8753d24c12.zip
pinctrl: imx1: fix device_node leak in dt_is_flat_functions()
for_each_child_of_node() holds a reference on the iterator node that must be released on early return. imx1_pinctrl_dt_is_flat_functions() has two early return paths inside the loop that skip this cleanup. Replace both loops with the scoped variant so that the reference is automatically dropped when the iterator goes out of scope. Fixes: 63d2059cd665 ("pinctrl: imx1: Allow parsing DT without function nodes") Signed-off-by: Felix Gu <ustc.gu@gmail.com> Reviewed-by: Frank Li <Frank.Li@nxp.com> Signed-off-by: Linus Walleij <linusw@kernel.org>
-rw-r--r--drivers/pinctrl/freescale/pinctrl-imx1-core.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/drivers/pinctrl/freescale/pinctrl-imx1-core.c b/drivers/pinctrl/freescale/pinctrl-imx1-core.c
index b7bd4ef9c0db..4a6bdaefa42f 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;
}