From: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
To: Linus Walleij <linusw@kernel.org>, Bartosz Golaszewski <brgl@kernel.org>
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>,
Marek Szyprowski <m.szyprowski@samsung.com>
Subject: [PATCH 2/2] gpio: shared: fix a race condition
Date: Mon, 05 Jan 2026 16:52:09 +0100 [thread overview]
Message-ID: <20260105-gpio-shared-fixes-v1-2-76d6ff0afcd8@oss.qualcomm.com> (raw)
In-Reply-To: <20260105-gpio-shared-fixes-v1-0-76d6ff0afcd8@oss.qualcomm.com>
When matching the reset-gpio reference with the actual firmware node
consuming the GPIO, we also need to lock the structure associated with
the latter as it can change while we're doing it.
Fixes: 49416483a953 ("gpio: shared: allow sharing a reset-gpios pin between reset-gpio and gpiolib")
Reported-by: Marek Szyprowski <m.szyprowski@samsung.com>
Closes: https://lore.kernel.org/all/00107523-7737-4b92-a785-14ce4e93b8cb@samsung.com/
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
---
drivers/gpio/gpiolib-shared.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/gpio/gpiolib-shared.c b/drivers/gpio/gpiolib-shared.c
index a68af06a6cc4e1e33946d7f200cecd4d3dc066af..198951c4c80bc0965c4b45a97f4f41ecc1f517b3 100644
--- a/drivers/gpio/gpiolib-shared.c
+++ b/drivers/gpio/gpiolib-shared.c
@@ -378,6 +378,8 @@ static bool gpio_shared_dev_is_reset_gpio(struct device *consumer,
* arguments match the ones from this consumer's node.
*/
list_for_each_entry(real_ref, &entry->refs, list) {
+ guard(mutex)(&real_ref->lock);
+
if (!real_ref->fwnode)
continue;
--
2.47.3
next prev parent reply other threads:[~2026-01-05 15:52 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <CGME20260105155232eucas1p1a0d0d603716267eacef8f57f7aa5e34f@eucas1p1.samsung.com>
2026-01-05 15:52 ` [PATCH 0/2] gpio: shared: another set of small fixes Bartosz Golaszewski
2026-01-05 15:52 ` [PATCH 1/2] gpio: shared: assign the correct firmware node for reset-gpio use-case Bartosz Golaszewski
2026-01-05 15:52 ` Bartosz Golaszewski [this message]
2026-01-05 16:48 ` [PATCH 0/2] gpio: shared: another set of small fixes Marek Szyprowski
2026-01-05 16:53 ` Bartosz Golaszewski
2026-01-05 17:22 ` Marek Szyprowski
2026-01-05 17:42 ` Bartosz Golaszewski
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=20260105-gpio-shared-fixes-v1-2-76d6ff0afcd8@oss.qualcomm.com \
--to=bartosz.golaszewski@oss.qualcomm.com \
--cc=brgl@kernel.org \
--cc=linusw@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=m.szyprowski@samsung.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®