From c370fe37ad31e80e027d0afed400323fa1b4d328 Mon Sep 17 00:00:00 2001 From: Aaron Durbin Date: Thu, 11 Feb 2016 16:08:49 -0600 Subject: soc/intel/apollolake: add assert for pad constraints Ensure the pads passed into the gpio functions are within range. Change-Id: Ic523cbfaf60a46709080347af3a36d6330f9a07c Signed-off-by: Aaron Durbin Reviewed-on: https://review.coreboot.org/13694 Tested-by: build bot (Jenkins) Reviewed-by: Martin Roth --- src/soc/intel/apollolake/gpio.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/soc/intel/apollolake/gpio.c b/src/soc/intel/apollolake/gpio.c index ab0e0ed9a4..5a68878051 100644 --- a/src/soc/intel/apollolake/gpio.c +++ b/src/soc/intel/apollolake/gpio.c @@ -10,6 +10,7 @@ * (at your option) any later version. */ +#include #include #include @@ -37,6 +38,8 @@ static const struct pad_community *gpio_get_community(uint16_t pad) { const struct pad_community *map = gpio_communities; + assert(pad < TOTAL_PADS); + while (map->first_pad > pad) map++; -- cgit v1.2.3