Re: [PATCH 2/4] pinctrl: renesas: rzn1: free maps on DT map failure
From: Geert Uytterhoeven
Date: Mon Sep 28 2026 - 09:32:06 EST
Hi Jiale,
On Thu, 24 Sept 2026 at 13:19, Jiale Yao <yaojiale02@xxxxxxx> wrote:
> rzn1_dt_node_to_map_one() appends mappings for each DT node. If a
> node fails after map storage has been reserved, the top-level callback
> returns without releasing mappings built for the current and previous
> nodes.
>
> Free the accumulated map and clear the output parameters on every error
> path.
>
> Signed-off-by: Jiale Yao <yaojiale02@xxxxxxx>
Thanks for your patch!
> --- a/drivers/pinctrl/renesas/pinctrl-rzn1.c
> +++ b/drivers/pinctrl/renesas/pinctrl-rzn1.c
> @@ -411,15 +411,21 @@ static int rzn1_dt_node_to_map(struct pinctrl_dev *pctldev,
>
> ret = rzn1_dt_node_to_map_one(pctldev, np, map, num_maps);
> if (ret < 0)
> - return ret;
> + goto err_free_map;
>
> for_each_child_of_node_scoped(np, child) {
> ret = rzn1_dt_node_to_map_one(pctldev, child, map, num_maps);
> if (ret < 0)
> - return ret;
> + goto err_free_map;
> }
>
> return 0;
> +
> +err_free_map:
> + pinctrl_utils_free_map(pctldev, *map, *num_maps);
Nice catch!
> + *map = NULL;
> + *num_maps = 0;
Is the resetting actually needed?
Only pinctrl-generic.c, pinctrl-sprd.c, and pinctrl-tegra-xusb.c seem
to do that.
> + return ret;
> }
>
> static const struct pinctrl_ops rzn1_pctrl_ops = {
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@xxxxxxxxxxxxxx
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds