Skip to content

Commit 810e154

Browse files
Junjie650Bartosz Golaszewski
authored andcommitted
gpio: timberdale: fix off-by-one in IRQ type boundary check
timbgpio_irq_type() currently accepts offset == ngpio, violating gpiolib's [0..ngpio-1] contract. This can lead to undefined behavior when computing '1 << offset', and it is also inconsistent with users that iterate with for_each_set_bit(..., ngpio). Tighten the upper bound to reject offset == ngpio. No functional change for in-range offsets. Signed-off-by: Junjie Cao <junjie.cao@intel.com> Link: https://lore.kernel.org/r/20250825090850.127163-1-junjie.cao@intel.com Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
1 parent 1b237f1 commit 810e154

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/gpio/gpio-timberdale.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ static int timbgpio_irq_type(struct irq_data *d, unsigned trigger)
137137
u32 ver;
138138
int ret = 0;
139139

140-
if (offset < 0 || offset > tgpio->gpio.ngpio)
140+
if (offset < 0 || offset >= tgpio->gpio.ngpio)
141141
return -EINVAL;
142142

143143
ver = ioread32(tgpio->membase + TGPIO_VER);

0 commit comments

Comments
 (0)