* [PATCH v2 0/4] pinctrl: free maps on DT mapping failures
@ 2026-10-03 8:31 Jiale Yao
2026-10-03 8:31 ` [PATCH v2 4/4] pinctrl: samsung: free maps on DT map failure Jiale Yao
0 siblings, 1 reply; 3+ messages in thread
From: Jiale Yao @ 2026-10-03 8:31 UTC (permalink / raw)
To: Geert Uytterhoeven, Linus Walleij, Krzysztof Kozlowski,
Sylwester Nawrocki, Peter Griffin, Alim Akhtar, Orson Zhai,
Baolin Wang, Chunyan Zhang, Thierry Reding, Jonathan Hunter,
linux-renesas-soc, linux-gpio, linux-kernel, linux-arm-kernel,
linux-samsung-soc, linux-tegra
Cc: Jiale Yao
Several pinctrl drivers reserve map storage before appending mux and
configuration entries while translating device tree nodes. If a later
operation fails, their error paths free only temporary configuration data
and leave the partially built map allocated.
Commit 17007cd70060 ("pinctrl: generic: free maps on
pinctrl_generic_to_map() failure") fixed the same cleanup problem in the
generic mapping helper. These drivers use their own mapping callbacks and
need equivalent error handling.
Free the accumulated map on every failure path in the Spreadtrum, Renesas
RZ/N1, Tegra XUSB, and Samsung drivers. Each patch changes one driver and
remains independently buildable.
Changes in v2:
- Add the Fixes tag and Baolin's Reviewed-by tag to patch 1.
- Drop the unnecessary output parameter resets from all four patches and
update their commit messages accordingly.
Jiale Yao (4):
pinctrl: sprd: free maps on DT map failure
pinctrl: renesas: rzn1: free maps on DT map failure
pinctrl: tegra: xusb: free maps on DT map failure
pinctrl: samsung: free maps on DT map failure
drivers/pinctrl/renesas/pinctrl-rzn1.c | 8 ++++++--
drivers/pinctrl/samsung/pinctrl-samsung.c | 24 ++++++++++++++--------
drivers/pinctrl/sprd/pinctrl-sprd.c | 3 +++
drivers/pinctrl/tegra/pinctrl-tegra-xusb.c | 6 +++++-
4 files changed, 29 insertions(+), 12 deletions(-)
--
2.34.1
^ permalink raw reply [flat|nested] 3+ messages in thread* [PATCH v2 4/4] pinctrl: samsung: free maps on DT map failure 2026-10-03 8:31 [PATCH v2 0/4] pinctrl: free maps on DT mapping failures Jiale Yao @ 2026-10-03 8:31 ` Jiale Yao 2026-10-07 10:35 ` Linus Walleij 0 siblings, 1 reply; 3+ messages in thread From: Jiale Yao @ 2026-10-03 8:31 UTC (permalink / raw) To: Krzysztof Kozlowski, Sylwester Nawrocki, Peter Griffin, Alim Akhtar, Linus Walleij, linux-arm-kernel, linux-samsung-soc, linux-gpio, linux-kernel Cc: Jiale Yao samsung_dt_subnode_to_map() can reserve map storage before adding configuration entries. The no-child path returns its error directly, and the child path frees mappings on failure. Use one error path that frees the accumulated map in both cases. 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. Signed-off-by: Jiale Yao <yaojiale02@163.com> --- drivers/pinctrl/samsung/pinctrl-samsung.c | 24 ++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/drivers/pinctrl/samsung/pinctrl-samsung.c b/drivers/pinctrl/samsung/pinctrl-samsung.c index 5ecc9ed4c44d..0a1e6063fb5f 100644 --- a/drivers/pinctrl/samsung/pinctrl-samsung.c +++ b/drivers/pinctrl/samsung/pinctrl-samsung.c @@ -259,22 +259,28 @@ static int samsung_dt_node_to_map(struct pinctrl_dev *pctldev, *map = NULL; *num_maps = 0; - if (!of_get_child_count(np_config)) - return samsung_dt_subnode_to_map(drvdata, pctldev->dev, - np_config, map, - &reserved_maps, - num_maps); + if (!of_get_child_count(np_config)) { + ret = samsung_dt_subnode_to_map(drvdata, pctldev->dev, + np_config, map, &reserved_maps, + num_maps); + if (ret < 0) + goto err_free_map; + + return 0; + } for_each_child_of_node_scoped(np_config, np) { ret = samsung_dt_subnode_to_map(drvdata, pctldev->dev, np, map, &reserved_maps, num_maps); - if (ret < 0) { - samsung_dt_free_map(pctldev, *map, *num_maps); - return ret; - } + if (ret < 0) + goto err_free_map; } return 0; + +err_free_map: + samsung_dt_free_map(pctldev, *map, *num_maps); + return ret; } #ifdef CONFIG_DEBUG_FS -- 2.34.1 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v2 4/4] pinctrl: samsung: free maps on DT map failure 2026-10-03 8:31 ` [PATCH v2 4/4] pinctrl: samsung: free maps on DT map failure Jiale Yao @ 2026-10-07 10:35 ` Linus Walleij 0 siblings, 0 replies; 3+ messages in thread From: Linus Walleij @ 2026-10-07 10:35 UTC (permalink / raw) To: Jiale Yao Cc: Krzysztof Kozlowski, Sylwester Nawrocki, Peter Griffin, Alim Akhtar, linux-arm-kernel, linux-samsung-soc, linux-gpio, linux-kernel On Sat, Oct 3, 2026 at 10:32 AM Jiale Yao <yaojiale02@163.com> wrote: > samsung_dt_subnode_to_map() can reserve map storage before adding > configuration entries. The no-child path returns its error directly, and > the child path frees mappings on failure. > > Use one error path that frees the accumulated map in both cases. 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. > > Signed-off-by: Jiale Yao <yaojiale02@163.com> Peter will decide and merge this patch. Yours, Linus Walleij ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-10-07 10:35 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-10-03 8:31 [PATCH v2 0/4] pinctrl: free maps on DT mapping failures Jiale Yao 2026-10-03 8:31 ` [PATCH v2 4/4] pinctrl: samsung: free maps on DT map failure Jiale Yao 2026-10-07 10:35 ` Linus Walleij
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox