From e873c665e503ebfb6dafaf9346c3956695686226 Mon Sep 17 00:00:00 2001 From: Jiale Yao Date: Sat, 3 Oct 2026 16:31:54 +0800 Subject: [PATCH] pinctrl: sprd: free maps on DT map failure 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 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. Fixes: 41d32cfce1ae ("pinctrl: sprd: Add Spreadtrum pin control driver") Signed-off-by: Jiale Yao Reviewed-by: Baolin Wang Signed-off-by: Linus Walleij --- drivers/pinctrl/sprd/pinctrl-sprd.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/pinctrl/sprd/pinctrl-sprd.c b/drivers/pinctrl/sprd/pinctrl-sprd.c index 16cf9d15f247..a565d4fd4233 100644 --- a/drivers/pinctrl/sprd/pinctrl-sprd.c +++ b/drivers/pinctrl/sprd/pinctrl-sprd.c @@ -326,6 +326,9 @@ 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); + return ret; }