From: sashiko-bot@kernel.org
To: "Xianwei Zhao via B4 Relay"
<devnull+xianwei.zhao.amlogic.com@kernel.org>
Cc: neil.armstrong@linaro.org, linux-amlogic@lists.infradead.org
Subject: Re: [PATCH] pinctrl: meson: amlogic-a4: use nolock get range
Date: Thu, 11 Jun 2026 07:26:19 +0000 [thread overview]
Message-ID: <20260611072620.15B801F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260611-pinctrl-nolock-v1-1-aca022d4d60f@amlogic.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [High] Lockless iteration of `pctldev->gpio_ranges` introduces a data race against concurrent list modifications.
Pre-existing issues:
- [High] Missing validation of `pinctrl_find_gpio_range_from_pin_nolock()` return value leading to NULL pointer dereference.
--
commit f9e63102e7090909caca32b069c2328643c7a837
Author: Xianwei Zhao <xianwei.zhao@amlogic.com>
pinctrl: meson: amlogic-a4: use nolock get range
This commit updates the amlogic-a4 pinctrl driver to use the nolock
variant of pinctrl_find_gpio_range_from_pin() when configuring pins or
setting GPIO values. This avoids taking the lock and allows the code to be
safely called from interrupt context.
> diff --git a/drivers/pinctrl/meson/pinctrl-amlogic-a4.c b/drivers/pinctrl/meson/pinctrl-amlogic-a4.c
> index 35d27626a336b..29702b363e222 100644
> --- a/drivers/pinctrl/meson/pinctrl-amlogic-a4.c
> +++ b/drivers/pinctrl/meson/pinctrl-amlogic-a4.c
> @@ -250,7 +250,7 @@ static int aml_pmx_set_mux(struct pinctrl_dev *pctldev, unsigned int fselector,
> int i;
>
> for (i = 0; i < group->npins; i++) {
> - range = pinctrl_find_gpio_range_from_pin(pctldev, group->pins[i]);
> + range = pinctrl_find_gpio_range_from_pin_nolock(pctldev, group->pins[i]);
[Severity: High]
Can this introduce a data race against concurrent list modifications?
The pctldev->gpio_ranges list is a standard doubly-linked list. Functions
like aml_pmx_set_mux() can be reached via pinctrl_select_state(), which
does not hold pctldev->mutex.
Because aml_pctl_probe() exposes the pinctrl device globally via
devm_pinctrl_register() before adding GPIO ranges via gpiochip_add_data(),
concurrent consumer probes could invoke these lockless traversals exactly
while list_add_tail() is actively mutating the list under pctldev->mutex.
Could this traverse corrupted list pointers and cause an infinite loop or
kernel panic?
[Severity: High]
This is a pre-existing issue, but does this missing NULL check lead to a
dereference if a pin is not found?
If a requested pin does not belong to any registered GPIO range,
pinctrl_find_gpio_range_from_pin_nolock() returns NULL. The returned range
pointer is then passed directly to aml_pctl_set_function() which
immediately dereferences it via range->gc in the gpio_chip_to_bank() macro:
aml_pctl_set_function()
struct aml_gpio_bank *bank = gpio_chip_to_bank(range->gc);
> aml_pctl_set_function(info, range, group->pins[i], group->func[i]);
> }
>
[ ... ]
> @@ -449,7 +449,7 @@ static int aml_pinconf_disable_bias(struct aml_pinctrl *info,
> unsigned int pin)
> {
> struct pinctrl_gpio_range *range =
> - pinctrl_find_gpio_range_from_pin(info->pctl, pin);
> + pinctrl_find_gpio_range_from_pin_nolock(info->pctl, pin);
> struct aml_gpio_bank *bank = gpio_chip_to_bank(range->gc);
[Severity: High]
This is a pre-existing issue, but as with aml_pmx_set_mux(), the return
value of pinctrl_find_gpio_range_from_pin_nolock() is immediately
dereferenced via range->gc. Should there be a check for NULL here as well?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260611-pinctrl-nolock-v1-1-aca022d4d60f@amlogic.com?part=1
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
next prev parent reply other threads:[~2026-06-11 7:26 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-11 7:10 [PATCH] pinctrl: meson: amlogic-a4: use nolock get range Xianwei Zhao via B4 Relay
2026-06-11 7:26 ` sashiko-bot [this message]
2026-06-11 12:40 ` 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=20260611072620.15B801F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=devnull+xianwei.zhao.amlogic.com@kernel.org \
--cc=linux-amlogic@lists.infradead.org \
--cc=neil.armstrong@linaro.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