[PATCH v2 3/4] pinctrl: tegra: xusb: free maps on DT map failure
From: Jiale Yao
Date: Sat Oct 03 2026 - 04:33:51 EST
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 <yaojiale02@xxxxxxx>
---
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 = {
--
2.34.1