linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gpiolib: of: fix bounds check for valid mask
@ 2022-04-11  6:33 Andrei Lalaev
  2022-04-11 10:48 ` Bartosz Golaszewski
  2022-04-11 12:12 ` Andy Shevchenko
  0 siblings, 2 replies; 9+ messages in thread
From: Andrei Lalaev @ 2022-04-11  6:33 UTC (permalink / raw)
  To: linus.walleij, brgl; +Cc: linux-gpio, linux-kernel, Andrei Lalaev

Use "greater" instead of "greater or equal" when performs bounds check
to make sure that GPIOS are in available range. Previous implementation
skipped ranges which include last GPIO in range.

Signed-off-by: Andrei Lalaev <andrei.lalaev@emlid.com>
---
 drivers/gpio/gpiolib-of.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index ae1ce319cd78..7e5e51d49d09 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -910,7 +910,7 @@ static void of_gpiochip_init_valid_mask(struct gpio_chip *chip)
 					   i, &start);
 		of_property_read_u32_index(np, "gpio-reserved-ranges",
 					   i + 1, &count);
-		if (start >= chip->ngpio || start + count >= chip->ngpio)
+		if (start >= chip->ngpio || start + count > chip->ngpio)
 			continue;
 
 		bitmap_clear(chip->valid_mask, start, count);
-- 
2.25.1


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

end of thread, other threads:[~2022-04-12  9:46 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-11  6:33 [PATCH] gpiolib: of: fix bounds check for valid mask Andrei Lalaev
2022-04-11 10:48 ` Bartosz Golaszewski
2022-04-11 12:12 ` Andy Shevchenko
2022-04-11 14:46   ` Andrei Lalaev
2022-04-11 16:55     ` Andy Shevchenko
2022-04-12  7:03       ` Andrei Lalaev
2022-04-12  8:35         ` Andy Shevchenko
2022-04-12  8:28   ` Bartosz Golaszewski
2022-04-12  8:36     ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).