aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorJunjie Cao <junjie.cao@intel.com>2025-08-25 17:08:50 +0800
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>2025-08-26 12:03:09 +0200
commit810e154d90f44127239957b06ee51a55553a5815 (patch)
tree2a9a6485b6f15a92441a15deb037d7a4ca78c0a1
parentLinux 6.17-rc3 (diff)
downloadwireguard-linux-810e154d90f44127239957b06ee51a55553a5815.tar.xz
wireguard-linux-810e154d90f44127239957b06ee51a55553a5815.zip
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>
-rw-r--r--drivers/gpio/gpio-timberdale.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/gpio/gpio-timberdale.c b/drivers/gpio/gpio-timberdale.c
index 679e27f00ff6..f488939dd00a 100644
--- a/drivers/gpio/gpio-timberdale.c
+++ b/drivers/gpio/gpio-timberdale.c
@@ -137,7 +137,7 @@ static int timbgpio_irq_type(struct irq_data *d, unsigned trigger)
u32 ver;
int ret = 0;
- if (offset < 0 || offset > tgpio->gpio.ngpio)
+ if (offset < 0 || offset >= tgpio->gpio.ngpio)
return -EINVAL;
ver = ioread32(tgpio->membase + TGPIO_VER);