aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpio
diff options
context:
space:
mode:
authorMika Westerberg <mika.westerberg@linux.intel.com>2014-04-01 06:03:00 -0400
committerLinus Walleij <linus.walleij@linaro.org>2014-04-14 04:22:36 -0400
commitb5539fa2d59d697b7b8e28b4d08da844ff60f7cf (patch)
tree7c78548114e5d19d31b6477f98600d54d5b26177 /drivers/gpio
parente9595f84a6273dffc5b75564d9b12a77630c529e (diff)
gpio / ACPI: Prevent potential wrap of GPIO value on OpRegion read
Dan Carpenter's static code checker reports: The patch 473ed7be0da0: "gpio / ACPI: Add support for ACPI GPIO operation regions" from Mar 14, 2014, leads to the following static checker warning: drivers/gpio/gpiolib-acpi.c:454 acpi_gpio_adr_space_handler() warn: should 'gpiod_get_raw_value(desc) << i' be a 64 bit type? This is due the fact that *value is of type u64 and gpiod_get_raw_value() returns int. Since i can be larger than 31, it is possible that the value returned gets wrapped. Fix this by casting the return of gpiod_get_raw_value() to u64 first before shift. Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio')
-rw-r--r--drivers/gpio/gpiolib-acpi.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index d5be56fe689e..401add28933f 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -451,7 +451,7 @@ acpi_gpio_adr_space_handler(u32 function, acpi_physical_address address,
451 if (function == ACPI_WRITE) 451 if (function == ACPI_WRITE)
452 gpiod_set_raw_value(desc, !!((1 << i) & *value)); 452 gpiod_set_raw_value(desc, !!((1 << i) & *value));
453 else 453 else
454 *value |= gpiod_get_raw_value(desc) << i; 454 *value |= (u64)gpiod_get_raw_value(desc) << i;
455 } 455 }
456 456
457out: 457out: