Skip to content

Commit b2132af

Browse files
Lu Hongfeilinusw
authored andcommitted
pinctrl: nxp: Fix resource leaks in for_each_child_of_node() loops
Ensure child node references are decremented properly in the error path. Signed-off-by: Lu Hongfei <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent e3275a8 commit b2132af

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

drivers/pinctrl/nxp/pinctrl-s32cc.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,10 @@ static int s32_dt_node_to_map(struct pinctrl_dev *pctldev,
279279
ret = s32_dt_group_node_to_map(pctldev, np, map,
280280
&reserved_maps, num_maps,
281281
np_config->name);
282-
if (ret < 0)
282+
if (ret < 0) {
283+
of_node_put(np);
283284
break;
285+
}
284286
}
285287

286288
if (ret)
@@ -812,8 +814,10 @@ static int s32_pinctrl_parse_functions(struct device_node *np,
812814
groups[i] = child->name;
813815
grp = &info->groups[info->grp_index++];
814816
ret = s32_pinctrl_parse_groups(child, grp, info);
815-
if (ret)
817+
if (ret) {
818+
of_node_put(child);
816819
return ret;
820+
}
817821
i++;
818822
}
819823

@@ -896,8 +900,10 @@ static int s32_pinctrl_probe_dt(struct platform_device *pdev,
896900
i = 0;
897901
for_each_child_of_node(np, child) {
898902
ret = s32_pinctrl_parse_functions(child, info, i++);
899-
if (ret)
903+
if (ret) {
904+
of_node_put(child);
900905
return ret;
906+
}
901907
}
902908

903909
return 0;

0 commit comments

Comments
 (0)