* [PATCH] pinctrl: imx: handle radix_tree_insert() errors in imx_pinctrl_parse_functions()
@ 2025-12-05 9:33 Haotian Zhang
0 siblings, 0 replies; only message in thread
From: Haotian Zhang @ 2025-12-05 9:33 UTC (permalink / raw)
To: linus.walleij
Cc: aisheng.dong, festevam, shawnguo, ping.bai, kernel, s32, s.hauer,
linux-gpio, imx, linux-arm-kernel, linux-kernel, Haotian Zhang
imx_pinctrl_parse_functions() doesn't check the result of
radix_tree_insert() which may return a negative error code
if the insertion fails.
Check the return value of radix_tree_insert() and return upon failure.
Fixes: a51c158bf0f7 ("pinctrl: imx: use radix trees for groups and functions")
Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
---
drivers/pinctrl/freescale/pinctrl-imx.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/drivers/pinctrl/freescale/pinctrl-imx.c b/drivers/pinctrl/freescale/pinctrl-imx.c
index 731c58ad43ee..c20bba7ea306 100644
--- a/drivers/pinctrl/freescale/pinctrl-imx.c
+++ b/drivers/pinctrl/freescale/pinctrl-imx.c
@@ -624,8 +624,14 @@ static int imx_pinctrl_parse_functions(struct device_node *np,
* FIXME: This should use pinctrl_generic_add_group() and not
* access the private radix tree directly.
*/
- radix_tree_insert(&pctl->pin_group_tree,
- ipctl->group_index++, grp);
+ ret = radix_tree_insert(&pctl->pin_group_tree,
+ ipctl->group_index, grp);
+ if (ret) {
+ mutex_unlock(&ipctl->mutex);
+ dev_err(ipctl->dev, "radix_tree_insert failed\n");
+ return ret;
+ }
+ ipctl->group_index++;
mutex_unlock(&ipctl->mutex);
imx_pinctrl_parse_groups(child, grp, ipctl, i++);
--
2.25.1
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2025-12-05 9:34 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-05 9:33 [PATCH] pinctrl: imx: handle radix_tree_insert() errors in imx_pinctrl_parse_functions() Haotian Zhang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).