Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Lee Jones" <lee@kernel.org>,
	linux-gpio@vger.kernel.org, imx@lists.linux.dev
Cc: Frank.Li@kernel.org
Subject: Re: [PATCH 02/12] pinctrl: imx: Validate pin_id in imx_pinctrl_parse_pin_mmio()
Date: Wed, 02 Dec 2026 09:50:55 +0000	[thread overview]
Message-ID: <sashiko-outbox-245365@kernel.org> (raw)
In-Reply-To: <3ff7bc09afe8aee89aa7ddc76acd1a0cf4e1dc87.1796203691.git.lee@kernel.org>

Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] pinctrl: imx: unhandled errors in imx_pinctrl_probe_dt() [1]
--

commit 6b0819d145656fd0c5efa904a33b1bacd1462e80
Author: Lee Jones <lee@kernel.org>

pinctrl: imx: Validate pin_id in imx_pinctrl_parse_pin_mmio()

This commit bounds-checks the derived pin_id against info->npins in
imx_pinctrl_parse_pin_mmio() and propagates -EINVAL to
imx_pinctrl_parse_groups().

> diff --git a/drivers/pinctrl/freescale/pinctrl-imx.c b/drivers/pinctrl/freescale/pinctrl-imx.c
> index ebcce9aeac8c3..0a825f58448f9 100644
> --- a/drivers/pinctrl/freescale/pinctrl-imx.c
> +++ b/drivers/pinctrl/freescale/pinctrl-imx.c

[ ... ]

> @@ -611,10 +621,16 @@ static int imx_pinctrl_parse_groups(struct device_node *np,
>  
>  	for (i = 0; i < grp->grp.npins; i++) {
>  		pin = &((struct imx_pin *)(grp->data))[i];
> -		if (info->flags & IMX_USE_SCU)
> +		if (info->flags & IMX_USE_SCU) {
>  			info->imx_pinctrl_parse_pin(ipctl, &pins[i], pin, &list);
> -		else
> -			imx_pinctrl_parse_pin_mmio(ipctl, &pins[i], pin, &list, np);
> +		} else {
> +			int ret;
> +
> +			ret = imx_pinctrl_parse_pin_mmio(ipctl, &pins[i], pin,
> +							 &list, np);
> +			if (ret)
> +				return ret;
> +		}
>  	}
>  
>  	return 0;

[Severity: High]
This problem wasn't introduced by this patch, but can returning an error
from imx_pinctrl_parse_groups() leave a partially initialized group
registered in pin_group_tree [1]?

imx_pinctrl_parse_functions() inserts grp into pctl->pin_group_tree and
then calls imx_pinctrl_parse_groups() without checking its return value,
and imx_pinctrl_probe_dt() likewise ignores the return value of
imx_pinctrl_parse_functions():

drivers/pinctrl/freescale/pinctrl-imx.c:imx_pinctrl_parse_functions() {
	...
		radix_tree_insert(&pctl->pin_group_tree,
				  ipctl->group_index++, grp);
		mutex_unlock(&ipctl->mutex);

		imx_pinctrl_parse_groups(child, grp, ipctl, i++);
	}
}

If imx_pinctrl_parse_groups() fails before allocating grp->data or
grp->grp.pins (or if a later pin entry fails after only part of the group
is populated), probing still succeeds and later group activation such as
imx_pmx_set() can dereference a NULL or unpopulated pin array.

[1] https://sashiko.dev/#/bug/linux-70c60bc4-5868-4c94-b1bb-7073f7a3316c

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/cover.1796203691.git.lee@kernel.org?part=2

  reply	other threads:[~2026-12-02  9:50 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-02  9:29 [PATCH 00/12] pinctrl: Fix Critical and High issues reported by Sashiko (batch 3) Lee Jones
2026-12-02  9:29 ` [PATCH 02/12] pinctrl: imx: Validate pin_id in imx_pinctrl_parse_pin_mmio() Lee Jones
2026-12-02  9:50   ` sashiko-bot [this message]
2026-12-02  9:29 ` [PATCH 04/12] pinctrl: imx: Propagate DT parsing errors in imx_pinctrl_probe_dt() Lee Jones
2026-12-02  9:30 ` [PATCH 06/12] pinctrl: imx: Serialise MMIO register updates with a spinlock Lee Jones

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=sashiko-outbox-245365@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=lee@kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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