[PATCH 3/4] pinctrl: tegra: xusb: free maps on DT map failure
From: Jiale Yao
Date: Thu Sep 24 2026 - 07:25:35 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 and clear the output parameters on failure.
Signed-off-by: Jiale Yao <yaojiale02@xxxxxxx>
---
drivers/pinctrl/tegra/pinctrl-tegra-xusb.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/drivers/pinctrl/tegra/pinctrl-tegra-xusb.c b/drivers/pinctrl/tegra/pinctrl-tegra-xusb.c
index c6a51bb21215..8873d7068867 100644
--- a/drivers/pinctrl/tegra/pinctrl-tegra-xusb.c
+++ b/drivers/pinctrl/tegra/pinctrl-tegra-xusb.c
@@ -248,10 +248,16 @@ 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);
+ *maps = NULL;
+ *num_maps = 0;
+ return err;
}
static const struct pinctrl_ops tegra_xusb_padctl_pinctrl_ops = {
--
2.34.1