[PATCH] pinctrl: imx1: fix device_node leak in dt_is_flat_functions()

Frank Li Frank.li at nxp.com
Sat May 23 07:34:37 PDT 2026


On Sat, May 23, 2026 at 06:27:05PM +0800, Felix Gu wrote:
> 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 at gmail.com>
> ---

Thank you for fix it.

Reviewed-by: Frank Li <Frank.Li at nxp.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 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;
>  		}
>
> ---
> base-commit: c1ecb239fa3456529a32255359fc78b69eb9d847
> change-id: 20260523-pinctrl-imx-b198f8391abf
>
> Best regards,
> --
> Felix Gu <ustc.gu at gmail.com>
>



More information about the linux-arm-kernel mailing list