From efd9330bb69732868a0ecc83df0a00553096bc8f Mon Sep 17 00:00:00 2001 From: Jiale Yao Date: Sat, 3 Oct 2026 16:31:56 +0800 Subject: [PATCH] pinctrl: tegra: xusb: free maps on DT map failure tegra_xusb_padctl_parse_subnode() can append mappings before a later child or configuration operation fails. The top-level callback currently returns the error while retaining all mappings allocated for earlier children. Free the accumulated map on failure. The caller ignores the output parameters when the mapping callback returns an error, so they do not need to be reset after freeing the map. Signed-off-by: Jiale Yao Signed-off-by: Linus Walleij --- drivers/pinctrl/tegra/pinctrl-tegra-xusb.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/drivers/pinctrl/tegra/pinctrl-tegra-xusb.c b/drivers/pinctrl/tegra/pinctrl-tegra-xusb.c index c6a51bb21215..fb70f8aee56b 100644 --- a/drivers/pinctrl/tegra/pinctrl-tegra-xusb.c +++ b/drivers/pinctrl/tegra/pinctrl-tegra-xusb.c @@ -248,10 +248,14 @@ static int tegra_xusb_padctl_dt_node_to_map(struct pinctrl_dev *pinctrl, &reserved_maps, num_maps); if (err < 0) - return err; + goto err_free_map; } return 0; + +err_free_map: + pinctrl_utils_free_map(pinctrl, *maps, *num_maps); + return err; } static const struct pinctrl_ops tegra_xusb_padctl_pinctrl_ops = {