Linux kernel -stable discussions
 help / color / mirror / Atom feed
* FAILED: patch "[PATCH] gpiolib: don't overwrite the entire flags field in" failed to apply to 6.12-stable tree
@ 2026-12-02 13:06 gregkh
  2026-12-02 15:01 ` [PATCH 6.12.y] gpiolib: don't overwrite the entire flags field in gpiod_get_direction() Kent Gibson
  0 siblings, 1 reply; 2+ messages in thread
From: gregkh @ 2026-12-02 13:06 UTC (permalink / raw)
  To: bartosz.golaszewski, warthog618; +Cc: stable


The patch below does not apply to the 6.12-stable tree.
If someone wants it applied there, or to any other stable or longterm
tree, then please email the backport, including the original git commit
id to <stable@vger.kernel.org>.

To reproduce the conflict and resubmit, you may use the following commands:

git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.12.y
git checkout FETCH_HEAD
git cherry-pick -x 8ed87a9adf48703b5729f9d020eb15fa79ffb099
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<stable@vger.kernel.org>' --in-reply-to '2026120226-attitude-radial-6af0@gregkh' --subject-prefix 'PATCH 6.12.y' 'HEAD^..'

Possible dependencies:



thanks,

greg k-h

------------------ original commit in Linus's tree ------------------

From 8ed87a9adf48703b5729f9d020eb15fa79ffb099 Mon Sep 17 00:00:00 2001
From: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Date: Tue, 10 Nov 2026 14:47:01 +0100
Subject: [PATCH] gpiolib: don't overwrite the entire flags field in
 gpiod_get_direction()

gpiod_get_direction() snapshots desc->flags with READ_ONCE(), updates
FLAG_IS_OUT in the local copy and writes the whole word back with
WRITE_ONCE(). Any bit that a concurrent user sets or clears atomically in
between - for instance: FLAG_USED_AS_IRQ from gpiochip_lock_as_irq() - is
silently lost.

Update FLAG_IS_OUT with a single atomic assign_bit() directly on
desc->flags. The earlier READ_ONCE() snapshot is only used for the
open-drain check and stays.

Cc: stable@vger.kernel.org
Fixes: 2559f2e09211 ("gpio: reinforce desc->flags handling")
Reviewed-by: Kent Gibson <warthog618@gmail.com>
Link: https://patch.msgid.link/20261110-gpio-desc-flags-atomic-v3-1-2f463bce8086@oss.qualcomm.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index acd3a1710f84..91041ce0fd49 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -489,8 +489,7 @@ int gpiod_get_direction(struct gpio_desc *desc)
 	if (ret > 0)
 		ret = 1;
 
-	assign_bit(GPIOD_FLAG_IS_OUT, &flags, !ret);
-	WRITE_ONCE(desc->flags, flags);
+	assign_bit(GPIOD_FLAG_IS_OUT, &desc->flags, !ret);
 
 	return ret;
 }


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH 6.12.y] gpiolib: don't overwrite the entire flags field in gpiod_get_direction()
  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:01 ` Kent Gibson
  0 siblings, 0 replies; 2+ messages in thread
From: Kent Gibson @ 2026-12-02 15:01 UTC (permalink / raw)
  To: stable; +Cc: Bartosz Golaszewski, Kent Gibson

From: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>

gpiod_get_direction() snapshots desc->flags with READ_ONCE(), updates
FLAG_IS_OUT in the local copy and writes the whole word back with
WRITE_ONCE(). Any bit that a concurrent user sets or clears atomically in
between - for instance: FLAG_USED_AS_IRQ from gpiochip_lock_as_irq() - is
silently lost.

Update FLAG_IS_OUT with a single atomic assign_bit() directly on
desc->flags. The earlier READ_ONCE() snapshot is only used for the
open-drain check and stays.

Cc: stable@vger.kernel.org
Fixes: 2559f2e09211 ("gpio: reinforce desc->flags handling")
Reviewed-by: Kent Gibson <warthog618@gmail.com>
Link: https://patch.msgid.link/20261110-gpio-desc-flags-atomic-v3-1-2f463bce8086@oss.qualcomm.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
(cherry picked from commit 8ed87a9adf48703b5729f9d020eb15fa79ffb099)
Signed-off-by: Kent Gibson <warthog618@gmail.com>
---
 drivers/gpio/gpiolib.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index c9dae5cf4db3..95b1a4824f4d 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -393,8 +393,7 @@ int gpiod_get_direction(struct gpio_desc *desc)
 	if (ret > 0)
 		ret = 1;
 
-	assign_bit(FLAG_IS_OUT, &flags, !ret);
-	WRITE_ONCE(desc->flags, flags);
+	assign_bit(FLAG_IS_OUT, &desc->flags, !ret);
 
 	return ret;
 }
-- 
2.56.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-02 15:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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:01 ` [PATCH 6.12.y] gpiolib: don't overwrite the entire flags field in gpiod_get_direction() Kent Gibson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox