summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Menzel <pmenzel@molgen.mpg.de>2016-08-12 14:08:49 +0200
committerMartin Roth <martinroth@google.com>2016-08-14 19:07:21 +0200
commit289f0578ce86bac8b0d03efa1244d0b0f8920364 (patch)
treef4ab6351b40c14a48fa5073fd5b012e18f4ac9fa /src
parent8ab989e31561cea0c6af5d5e242dd2be97bc73b4 (diff)
cpu/ti/am355x: Fix array overrun
> Overrunning array "am335x_gpio_banks" of 4 4-byte elements at element > index 4 (byte offset 16) using index "bank" (which evaluates to 4). As the first index is 0, also error out if the index is equal the array size. Change-Id: I6b6b6e010348a58931bd546dfc54f08460e8dbbc Found-by: Coverity (CID 1354615: Memory - illegal accesses (OVERRUN)) Signed-off-by: Paul Menzel <pmenzel@molgen.mpg.de> Reviewed-on: https://review.coreboot.org/16165 Tested-by: build bot (Jenkins) Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Diffstat (limited to 'src')
-rw-r--r--src/cpu/ti/am335x/gpio.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/cpu/ti/am335x/gpio.c b/src/cpu/ti/am335x/gpio.c
index d4f7edfb72..bfbbbd2698 100644
--- a/src/cpu/ti/am335x/gpio.c
+++ b/src/cpu/ti/am335x/gpio.c
@@ -22,7 +22,7 @@ static struct am335x_gpio_regs *gpio_regs_and_bit(unsigned gpio, uint32_t *bit)
{
unsigned bank = gpio / AM335X_GPIO_BITS_PER_BANK;
- if (bank > ARRAY_SIZE(am335x_gpio_banks)) {
+ if (bank >= ARRAY_SIZE(am335x_gpio_banks)) {
printk(BIOS_ERR, "Bad gpio index %d.\n", gpio);
return NULL;
}