* [PATCH 5.10] gpiolib: acpi: handle overflow check in acpi_gpio_adr_space_handler()
@ 2025-11-10 15:25 Alexandr Sapozhnikov
0 siblings, 0 replies; only message in thread
From: Alexandr Sapozhnikov @ 2025-11-10 15:25 UTC (permalink / raw)
To: Mika Westerberg, Andy Shevchenko, Linus Walleij,
Bartosz Golaszewski
Cc: Alexandr Sapozhnikov, linux-gpio, linux-acpi, linux-kernel
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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2025-11-10 15:25 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-10 15:25 [PATCH 5.10] gpiolib: acpi: handle overflow check in acpi_gpio_adr_space_handler() Alexandr Sapozhnikov
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).