summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Spiegel <richard.spiegel@amd.corp-partner.google.com>2018-08-20 16:59:02 -0700
committerMartin Roth <martinroth@google.com>2018-08-28 15:36:51 +0000
commit4cafc886195a52a0610c46c79fbb700294e9f1aa (patch)
tree8d9b02066ff2b059bf261493b81511d31c1960eb
parent78f2343aa2d4fb606423cba4251252e033f41c6c (diff)
downloadcoreboot-4cafc886195a52a0610c46c79fbb700294e9f1aa.tar.xz
lib/gpio.c: Validate num_gpio
In function _gpio_base3_value(), if num_gpio is 0 it'll cause the return of an undefined value, as no for loop will be executed. Assert that it's not 0. BUG=b:112253891 TEST=Build and boot grunt. Change-Id: I2b6537900fa41ebbee0171959f3ce236d360bc80 Signed-off-by: Richard Spiegel <richard.spiegel@silverbackltd.com> Reviewed-on: https://review.coreboot.org/28249 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Martin Roth <martinroth@google.com>
-rw-r--r--src/lib/gpio.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/lib/gpio.c b/src/lib/gpio.c
index 0656dfb870..da748492fc 100644
--- a/src/lib/gpio.c
+++ b/src/lib/gpio.c
@@ -82,7 +82,8 @@ uint32_t _gpio_base3_value(const gpio_t gpio[], int num_gpio, int binary_first)
int index;
int temp;
char value[32];
- assert(num_gpio <= 32);
+ if ((num_gpio > 32) && (num_gpio < 1))
+ die("gpio_base3_value: Invalid number of GPIOs");
/* Enable internal pull up */
for (index = 0; index < num_gpio; ++index)