[PATCH 2/5] gpiolib: fix fast-path cancellation in gpiod_get_array()
From: Dmitry Torokhov
Date: Wed Oct 21 2026 - 15:02:29 EST
In gpiod_get_array(), when a pin on the same chip is not in hardware
order and the preceding pins form a contiguous block, the fast path is
cancelled by setting array_info to NULL. However, descs->info was
already populated with the array_info pointer during the first
iteration, leaving descs->info pointing to the aborted array_info.
Consequently, subsequent array operations still use the fast path with
remaining bits set in the masks and wrong hardware pin numbers.
Clear descs->info alongside array_info when cancelling the fast path so
callers do not erroneously use the aborted array_info.
Fixes: c4c958aa64f3 ("gpiolib: Fix array members of same chip processed separately")
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@xxxxxxxxx>
---
drivers/gpio/gpiolib.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 21c9cea71c68..144a63e6692c 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -5270,6 +5270,7 @@ struct gpio_descs *__must_check gpiod_get_array(struct device *dev,
* hardware number is different from its array index.
*/
if (bitmap_full(array_info->get_mask, i)) {
+ descs->info = NULL;
array_info = NULL;
} else {
__clear_bit(i, array_info->get_mask);
--
2.56.0.307.g5fe7bd680c-goog