[PATCH 1/4] pinctrl: sprd: free maps on DT map failure

From: Jiale Yao

Date: Thu Sep 24 2026 - 07:23:39 EST


sprd_dt_node_to_map() reserves map storage before adding mux and
configuration entries. If a later operation fails, the error path only
frees the temporary configurations and leaves the map allocation reachable
through the output pointer.

Free the partially built map and clear the output parameters on failure.

Signed-off-by: Jiale Yao <yaojiale02@xxxxxxx>
---
drivers/pinctrl/sprd/pinctrl-sprd.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/drivers/pinctrl/sprd/pinctrl-sprd.c b/drivers/pinctrl/sprd/pinctrl-sprd.c
index 16cf9d15f247..218ac5236e95 100644
--- a/drivers/pinctrl/sprd/pinctrl-sprd.c
+++ b/drivers/pinctrl/sprd/pinctrl-sprd.c
@@ -326,6 +326,12 @@ static int sprd_dt_node_to_map(struct pinctrl_dev *pctldev,

out:
kfree(configs);
+ if (ret < 0) {
+ pinctrl_utils_free_map(pctldev, *map, *num_maps);
+ *map = NULL;
+ *num_maps = 0;
+ }
+
return ret;
}

--
2.34.1