diff mbox series

[v2,3/4] pinctrl: tegra: xusb: free maps on DT map failure

Message ID 20261003083200.459705-4-yaojiale02@163.com
State New
Headers show
Series pinctrl: free maps on DT mapping failures | expand

Commit Message

Jiale Yao Oct. 3, 2026, 8:31 a.m. UTC
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@163.com>
---
 drivers/pinctrl/tegra/pinctrl-tegra-xusb.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Linus Walleij Oct. 7, 2026, 10:34 a.m. UTC | #1
On Sat, Oct 3, 2026 at 10:32 AM Jiale Yao <yaojiale02@163.com> wrote:

> 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@163.com>

Patch applied.

Yours,
Linus Walleij
diff mbox series

Patch

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 = {