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: 41d32cfce1 ("pinctrl: sprd: Add Spreadtrum pin control driver")
Signed-off-by: Jiale Yao <yaojiale02@163.com>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Signed-off-by: Linus Walleij <linusw@kernel.org>
This commit is contained in:
Jiale Yao 2026-10-03 16:31:54 +08:00 committed by Linus Walleij
parent c4e625828a
commit e873c665e5

View File

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