From: Jiale Yao <yaojiale02@163.com>
To: Geert Uytterhoeven <geert+renesas@glider.be>,
Linus Walleij <linusw@kernel.org>,
Orson Zhai <orsonzhai@gmail.com>,
Baolin Wang <baolin.wang@linux.alibaba.com>,
Chunyan Zhang <zhang.lyra@gmail.com>,
Thierry Reding <thierry.reding@kernel.org>,
Jonathan Hunter <jonathanh@nvidia.com>,
Krzysztof Kozlowski <krzysztof.kozlowski@oss.qualcomm.com>,
linux-renesas-soc@vger.kernel.org, linux-gpio@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-tegra@vger.kernel.org
Cc: Jiale Yao <yaojiale02@163.com>
Subject: [PATCH 4/4] pinctrl: samsung: free maps on DT map failure
Date: Thu, 24 Sep 2026 19:18:52 +0800 [thread overview]
Message-ID: <20260924111856.622898-5-yaojiale02@163.com> (raw)
In-Reply-To: <20260924111856.622898-1-yaojiale02@163.com>
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 without clearing the output parameters.
Use one error path that frees the accumulated map and clears the output
parameters for both cases.
Signed-off-by: Jiale Yao <yaojiale02@163.com>
---
drivers/pinctrl/samsung/pinctrl-samsung.c | 26 +++++++++++++++--------
1 file changed, 17 insertions(+), 9 deletions(-)
diff --git a/drivers/pinctrl/samsung/pinctrl-samsung.c b/drivers/pinctrl/samsung/pinctrl-samsung.c
index 5ecc9ed4c44d..4b202fbbcb80 100644
--- a/drivers/pinctrl/samsung/pinctrl-samsung.c
+++ b/drivers/pinctrl/samsung/pinctrl-samsung.c
@@ -259,22 +259,30 @@ 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);
+ *map = NULL;
+ *num_maps = 0;
+ return ret;
}
#ifdef CONFIG_DEBUG_FS
--
2.34.1
next prev parent reply other threads:[~2026-09-24 11:19 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-24 11:18 [PATCH 0/4] pinctrl: free maps on DT mapping failures Jiale Yao
2026-09-24 11:18 ` [PATCH 1/4] pinctrl: sprd: free maps on DT map failure Jiale Yao
2026-09-29 6:08 ` Baolin Wang
2026-09-24 11:18 ` [PATCH 2/4] pinctrl: renesas: rzn1: " Jiale Yao
2026-09-28 13:19 ` Geert Uytterhoeven
2026-09-29 8:07 ` jiale yao
2026-10-01 12:45 ` Thierry Reding
2026-10-03 8:34 ` jiale yao
2026-09-24 11:18 ` [PATCH 3/4] pinctrl: tegra: xusb: " Jiale Yao
2026-09-24 11:18 ` Jiale Yao [this message]
2026-10-01 7:49 ` [PATCH 0/4] pinctrl: free maps on DT mapping failures Linus Walleij
2026-10-01 12:42 ` Thierry Reding
2026-10-01 19:47 ` Linus Walleij
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260924111856.622898-5-yaojiale02@163.com \
--to=yaojiale02@163.com \
--cc=baolin.wang@linux.alibaba.com \
--cc=geert+renesas@glider.be \
--cc=jonathanh@nvidia.com \
--cc=krzysztof.kozlowski@oss.qualcomm.com \
--cc=linusw@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=orsonzhai@gmail.com \
--cc=thierry.reding@kernel.org \
--cc=zhang.lyra@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox