linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexandr Sapozhnikov <alsp705@gmail.com>
To: Mika Westerberg <mika.westerberg@linux.intel.com>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Bartosz Golaszewski <bgolaszewski@baylibre.com>
Cc: Alexandr Sapozhnikov <alsp705@gmail.com>,
	linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH 5.10] gpiolib: acpi: handle overflow check in acpi_gpio_adr_space_handler()
Date: Mon, 10 Nov 2025 18:25:44 +0300	[thread overview]
Message-ID: <20251110152545.11-1-alsp705@gmail.com> (raw)

Added an overflow check when setting a bit, since the function will not work 
correctly if there is an overflow.

Found by Linux Verification Center (linuxtesting.org) with svace.

Fixes: dc62b56a68d3 ("gpio / ACPI: use *_cansleep version of gpiod_get/set APIs")
Signed-off-by: Alexandr Sapozhnikov <alsp705@gmail.com>
---
 drivers/gpio/gpiolib-acpi.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index 834a12f3219e..dfb421bff979 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -1069,6 +1069,11 @@ acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address,
 
 		mutex_unlock(&achip->conn_lock);
 
+		if (i < 0 || i > 64) {
+			status=-EINVAL;
+			goto out;
+		}
+
 		if (function == ACPI_WRITE)
 			gpiod_set_raw_value_cansleep(desc,
 						     !!((1 << i) & *value));
-- 
2.51.0


                 reply	other threads:[~2025-11-10 15:25 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20251110152545.11-1-alsp705@gmail.com \
    --to=alsp705@gmail.com \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=bgolaszewski@baylibre.com \
    --cc=linus.walleij@linaro.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    /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 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).