From: Kent Gibson <warthog618@gmail.com>
To: stable@vger.kernel.org
Cc: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>,
Kent Gibson <warthog618@gmail.com>
Subject: [PATCH 6.12.y] gpiolib: don't overwrite the entire flags field in gpiod_free_commit()
Date: Wed, 2 Dec 2026 23:27:33 +0800 [thread overview]
Message-ID: <20261202152733.137813-1-warthog618@gmail.com> (raw)
In-Reply-To: <2026120234-hazing-ramrod-aee2@gregkh>
From: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Use set_mask_bits() to clear all request-related flags in one go
instead of risking racing with concurrent users and overwriting any
changes they could have done between READ_ONCE() and WRITE_ONCE().
Cc: stable@vger.kernel.org
Fixes: 35b545332b80 ("gpio: remove gpio_lock")
Reviewed-by: Kent Gibson <warthog618@gmail.com>
Link: https://patch.msgid.link/20261110-gpio-desc-flags-atomic-v3-4-2f463bce8086@oss.qualcomm.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
(cherry picked from commit 63d7aedf6add8a24415af4c010588f63fa7296ab)
Signed-off-by: Kent Gibson <warthog618@gmail.com>
---
drivers/gpio/gpiolib.c | 27 +++++++++++++--------------
1 file changed, 13 insertions(+), 14 deletions(-)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index c9dae5cf4db3..ff17237924e4 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -2427,24 +2427,23 @@ static void gpiod_free_commit(struct gpio_desc *desc)
if (guard.gc->free)
guard.gc->free(guard.gc, gpio_chip_hwgpio(desc));
- clear_bit(FLAG_ACTIVE_LOW, &flags);
- clear_bit(FLAG_REQUESTED, &flags);
- clear_bit(FLAG_OPEN_DRAIN, &flags);
- clear_bit(FLAG_OPEN_SOURCE, &flags);
- clear_bit(FLAG_PULL_UP, &flags);
- clear_bit(FLAG_PULL_DOWN, &flags);
- clear_bit(FLAG_BIAS_DISABLE, &flags);
- clear_bit(FLAG_EDGE_RISING, &flags);
- clear_bit(FLAG_EDGE_FALLING, &flags);
- clear_bit(FLAG_EVENT_CLOCK_REALTIME, &flags);
- clear_bit(FLAG_EVENT_CLOCK_HTE, &flags);
- clear_bit(FLAG_IS_HOGGED, &flags);
#ifdef CONFIG_OF_DYNAMIC
WRITE_ONCE(desc->hog, NULL);
#endif
desc_set_label(desc, NULL);
- WRITE_ONCE(desc->flags, flags);
-
+ set_mask_bits(&desc->flags,
+ BIT(FLAG_ACTIVE_LOW) |
+ BIT(FLAG_REQUESTED) |
+ BIT(FLAG_OPEN_DRAIN) |
+ BIT(FLAG_OPEN_SOURCE) |
+ BIT(FLAG_PULL_UP) |
+ BIT(FLAG_PULL_DOWN) |
+ BIT(FLAG_BIAS_DISABLE) |
+ BIT(FLAG_EDGE_RISING) |
+ BIT(FLAG_EDGE_FALLING) |
+ BIT(FLAG_EVENT_CLOCK_REALTIME) |
+ BIT(FLAG_EVENT_CLOCK_HTE) |
+ BIT(FLAG_IS_HOGGED), 0);
gpiod_line_state_notify(desc, GPIOLINE_CHANGED_RELEASED);
}
}
--
2.56.1
prev parent reply other threads:[~2026-12-02 15:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 13:06 FAILED: patch "[PATCH] gpiolib: don't overwrite the entire flags field in" failed to apply to 6.12-stable tree gregkh
2026-12-02 15:27 ` Kent Gibson [this message]
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=20261202152733.137813-1-warthog618@gmail.com \
--to=warthog618@gmail.com \
--cc=bartosz.golaszewski@oss.qualcomm.com \
--cc=stable@vger.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