]> git.baikalelectronics.ru Git - kernel.git/commit
gpio / ACPI: Prevent potential wrap of GPIO value on OpRegion read
authorMika Westerberg <mika.westerberg@linux.intel.com>
Tue, 1 Apr 2014 10:03:00 +0000 (13:03 +0300)
committerLinus Walleij <linus.walleij@linaro.org>
Mon, 14 Apr 2014 08:22:36 +0000 (10:22 +0200)
commitc6afe9bd3d4a21200fc2815657d89470721f77e6
tree7c78548114e5d19d31b6477f98600d54d5b26177
parent68dc6acba20600f51ed6012b227eaf06e73648b2
gpio / ACPI: Prevent potential wrap of GPIO value on OpRegion read

Dan Carpenter's static code checker reports:

 The patch 84427f056260: "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>
drivers/gpio/gpiolib-acpi.c