Skip to contentSkip to conversation

gpiolib: acpi: handle overflow check in acpi_gpio_adr_space_handler()

PATCH New Alexandr Sapozhnikov 1 participant 1 message Nov 10, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 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")
---
 drivers/gpio/gpiolib-acpi.c | 5 +++++
 1 file changed, 5 insertions(+)
drivers/gpio/gpiolib-acpi.c +5 -0
index 834a12f3219e..dfb421bff979 100644
@@ -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));
Signature · 1 line
2.51.0