Linux GPIO subsystem development
 help / color / mirror / Atom feed
* [PATCH] pinctrl: generic-mux: free maps on pinctrl_generic_to_map() failure
@ 2026-07-23  6:30 kr494167
  2026-07-24 18:46 ` Frank Li
  0 siblings, 1 reply; 2+ messages in thread
From: kr494167 @ 2026-07-23  6:30 UTC (permalink / raw)
  To: linusw; +Cc: Frank.Li, linux-gpio, linux-kernel, Surendra Singh Chouhan

From: Surendra Singh Chouhan <kr494167@gmail.com>

mux_pinmux_dt_node_to_map() calls pinctrl_generic_to_map() to parse DT
configuration and allocate pinctrl maps.

If pinctrl_generic_to_map() returns an error, *maps may contain partial
map entries allocated by pinctrl_utils_reserve_map(). Returning the error
directly without calling pinctrl_utils_free_map() leaks the allocated
mapping memory.

Fix this by calling pinctrl_utils_free_map() when pinctrl_generic_to_map()
fails.

Fixes: 34acc5a8adfb ("pinctrl: add generic board-level pinctrl driver using mux framework")
Signed-off-by: Surendra Singh Chouhan <kr494167@gmail.com>
---
 drivers/pinctrl/pinctrl-generic-mux.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/pinctrl/pinctrl-generic-mux.c b/drivers/pinctrl/pinctrl-generic-mux.c
index da5a5ec01583..927c7aa616f5 100644
--- a/drivers/pinctrl/pinctrl-generic-mux.c
+++ b/drivers/pinctrl/pinctrl-generic-mux.c
@@ -58,8 +58,10 @@ mux_pinmux_dt_node_to_map(struct pinctrl_dev *pctldev,
 				     num_maps, &num_reserved_maps, group_names,
 				     0, &np_config->name, NULL, 0);
 
-	if (ret)
+	if (ret) {
+		pinctrl_utils_free_map(pctldev, *maps, *num_maps);
 		return ret;
+	}
 
 	ret = pinmux_generic_add_function(pctldev, np_config->name, group_names,
 					  1, function);
-- 
2.55.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-07-24 18:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-23  6:30 [PATCH] pinctrl: generic-mux: free maps on pinctrl_generic_to_map() failure kr494167
2026-07-24 18:46 ` Frank Li

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox