linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Haotian Zhang <vulab@iscas.ac.cn>
To: linus.walleij@linaro.org
Cc: aisheng.dong@nxp.com, festevam@gmail.com, shawnguo@kernel.org,
	ping.bai@nxp.com, kernel@pengutronix.de, s32@nxp.com,
	s.hauer@pengutronix.de, linux-gpio@vger.kernel.org,
	imx@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, Haotian Zhang <vulab@iscas.ac.cn>
Subject: [PATCH] pinctrl: imx: handle radix_tree_insert() errors in imx_pinctrl_parse_functions()
Date: Fri,  5 Dec 2025 17:33:08 +0800	[thread overview]
Message-ID: <20251205093308.1498-1-vulab@iscas.ac.cn> (raw)

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


                 reply	other threads:[~2025-12-05  9:34 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20251205093308.1498-1-vulab@iscas.ac.cn \
    --to=vulab@iscas.ac.cn \
    --cc=aisheng.dong@nxp.com \
    --cc=festevam@gmail.com \
    --cc=imx@lists.linux.dev \
    --cc=kernel@pengutronix.de \
    --cc=linus.walleij@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ping.bai@nxp.com \
    --cc=s.hauer@pengutronix.de \
    --cc=s32@nxp.com \
    --cc=shawnguo@kernel.org \
    /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;
as well as URLs for NNTP newsgroup(s).