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

From: Baolin Wang

Date: Tue Sep 29 2026 - 02:12:33 EST




On 9/24/26 7:18 PM, Jiale Yao wrote:
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>
---

LGTM. Please add the Fixes tag:

Fixes: 41d32cfce1ae ("pinctrl: sprd: Add Spreadtrum pin control driver")

Reviewed-by: Baolin Wang <baolin.wang@xxxxxxxxxxxxxxxxx>

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;
}