Skip to content

Commit c0ae43d

Browse files
Denis SergeevBartosz Golaszewski
authored andcommitted
gpiolib: acpi: use BIT_ULL() for u64 mask in address space handler
The BIT() macro uses unsigned long, which is 32 bits on 32-bit architectures. When iterating over GPIO pins with index >= 32, the expression (*value & BIT(i)) causes undefined behavior due to shifting by a value >= type width. Since 'value' is a pointer to u64, use BIT_ULL() to ensure correct 64-bit mask on all architectures. Found by Linux Verification Center (linuxtesting.org) with Svace. Fixes: 2c4d00c ("gpiolib: acpi: Use BIT() macro to increase readability") Signed-off-by: Denis Sergeev <denserg.edu@gmail.com> Reviewed-by: Mika Westerberg <westeri@kernel.org> Link: https://lore.kernel.org/r/20260126035914.16586-1-denserg.edu@gmail.com Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
1 parent 96313fc commit c0ae43d

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

drivers/gpio/gpiolib-acpi-core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1159,7 +1159,7 @@ acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address,
11591159
mutex_unlock(&achip->conn_lock);
11601160

11611161
if (function == ACPI_WRITE)
1162-
gpiod_set_raw_value_cansleep(desc, !!(*value & BIT(i)));
1162+
gpiod_set_raw_value_cansleep(desc, !!(*value & BIT_ULL(i)));
11631163
else
11641164
*value |= (u64)gpiod_get_raw_value_cansleep(desc) << i;
11651165
}

0 commit comments

Comments
 (0)