summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Durbin <adurbin@chromium.org>2016-02-11 16:08:49 -0600
committerAaron Durbin <adurbin@chromium.org>2016-02-13 01:16:27 +0100
commitc370fe37ad31e80e027d0afed400323fa1b4d328 (patch)
tree71ad76500142fa444d637089cf46127cdcec6a16
parentc65b8f128e25346ba01b90cb4f59d07ea84157af (diff)
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 <adurbin@chromium.org> Reviewed-on: https://review.coreboot.org/13694 Tested-by: build bot (Jenkins) Reviewed-by: Martin Roth <martinroth@google.com>
-rw-r--r--src/soc/intel/apollolake/gpio.c3
1 files changed, 3 insertions, 0 deletions
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 <assert.h>
#include <soc/gpio.h>
#include <soc/iosf.h>
@@ -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++;