All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrei Lalaev <andrei.lalaev@emlid.com>
To: linus.walleij@linaro.org, brgl@bgdev.pl
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
	Andrei Lalaev <andrei.lalaev@emlid.com>
Subject: [PATCH] gpiolib: of: fix bounds check for valid mask
Date: Mon, 11 Apr 2022 09:33:25 +0300	[thread overview]
Message-ID: <20220411063324.98542-1-andrei.lalaev@emlid.com> (raw)

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


             reply	other threads:[~2022-04-11  6:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-11  6:33 Andrei Lalaev [this message]
2022-04-11 10:48 ` [PATCH] gpiolib: of: fix bounds check for valid mask 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220411063324.98542-1-andrei.lalaev@emlid.com \
    --to=andrei.lalaev@emlid.com \
    --cc=brgl@bgdev.pl \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.