From: sashiko-bot@kernel.org
To: "Shawn Guo" <shengchao.guo@oss.qualcomm.com>
Cc: linux-gpio@vger.kernel.org
Subject: Re: [PATCH v2 1/2] gpio: shared-proxy: Fix race between concurrent first users
Date: Fri, 16 Oct 2026 14:58:22 +0000 [thread overview]
Message-ID: <sashiko-outbox-174507@kernel.org> (raw)
In-Reply-To: <20261016144919.1362846-2-shengchao.guo@oss.qualcomm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] gpio: shared: set_value(0) is a no-op on ASIS lines driven HIGH
--
commit b2e913f9e7adbb02eb24728f50149f4b95e20857
Author: Shawn Guo <shengchao.guo@oss.qualcomm.com>
gpio: shared-proxy: Fix race between concurrent first users
This commit fixes a race condition where multiple consumers probing concurrently
can both request a shared GPIO before either configures it, causing both to fail.
It tracks the number of proxies that have actually configured the line, allowing
initialization only when no other proxy has done so.
> diff --git a/drivers/gpio/gpio-shared-proxy.c b/drivers/gpio/gpio-shared-proxy.c
> index bc69b8729d196..0d1d724a6a376 100644
> --- a/drivers/gpio/gpio-shared-proxy.c
> +++ b/drivers/gpio/gpio-shared-proxy.c
[ ... ]
> @@ -230,10 +275,21 @@ static int gpio_shared_proxy_set_cansleep(struct gpio_chip *gc,
> unsigned int offset, int value)
> {
> struct gpio_shared_proxy_data *proxy = gpiochip_get_data(gc);
> + int ret;
>
> guard(mutex)(&proxy->shared_desc->mutex);
>
> - return gpio_shared_proxy_set_unlocked(proxy, value);
> + /*
> + * A GPIOD_ASIS consumer may vote without ever setting the direction;
> + * count it as configured so a later user can't reset its vote.
> + */
> + ret = gpio_shared_proxy_set_unlocked(proxy, value);
[Severity: Medium]
If a consumer requests a shared GPIO with GPIOD_ASIS and the physical line
is already driven HIGH, does shared_desc->def_val still default to 0?
When the consumer later calls gpiod_set_value(0) to drive the line LOW,
gpio_shared_proxy_set_unlocked() checks if value != shared_desc->def_val.
Since both value and def_val are 0, it skips calling
gpiod_set_value_cansleep() and returns success without changing the
hardware state.
Does this result in set_value(0) acting as a no-op on ASIS lines that are
initially driven HIGH?
> + if (ret)
> + return ret;
> +
> + gpio_shared_proxy_mark_configured(proxy);
> +
> + return 0;
> }
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261016144919.1362846-1-shengchao.guo@oss.qualcomm.com?part=1
next prev parent reply other threads:[~2026-10-16 14:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-16 14:49 [PATCH v2 0/2] gpio: shared-proxy: Fix line accounting Shawn Guo
2026-10-16 14:49 ` [PATCH v2 1/2] gpio: shared-proxy: Fix race between concurrent first users Shawn Guo
2026-10-16 14:58 ` sashiko-bot [this message]
2026-10-16 14:49 ` [PATCH v2 2/2] gpio: shared-proxy: Drop the vote of a released proxy on write failure Shawn Guo
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-174507@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=shengchao.guo@oss.qualcomm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.