[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20251110152545.11-1-alsp705@gmail.com>
Date: Mon, 10 Nov 2025 18:25:44 +0300
From: Alexandr Sapozhnikov <alsp705@...il.com>
To: Mika Westerberg <mika.westerberg@...ux.intel.com>,
Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
Linus Walleij <linus.walleij@...aro.org>,
Bartosz Golaszewski <bgolaszewski@...libre.com>
Cc: Alexandr Sapozhnikov <alsp705@...il.com>,
linux-gpio@...r.kernel.org,
linux-acpi@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH 5.10] gpiolib: acpi: handle overflow check in acpi_gpio_adr_space_handler()
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@...il.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
Powered by blists - more mailing lists