From 4b76fbd14cb90cc76579b12cb1ca13c863fc61cc Mon Sep 17 00:00:00 2001 From: Brendan Le Foll Date: Thu, 18 Feb 2016 17:22:22 +0000 Subject: [PATCH] mraa: with NULL platform board max counts need to be checked to >= not just > This fixes bugs when USBPLAT or FIRMATA is enabled when a NULL platform is added or even a platform without ADC Signed-off-by: Brendan Le Foll --- src/aio/aio.c | 2 +- src/gpio/gpio.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/aio/aio.c b/src/aio/aio.c index 92aa9f4..5335b5e 100644 --- a/src/aio/aio.c +++ b/src/aio/aio.c @@ -107,7 +107,7 @@ mraa_aio_init(unsigned int aio) syslog(LOG_ERR, "aio: pin %i beyond platform definition", pin); return NULL; } - if (aio > board->aio_count) { + if (aio >= board->aio_count) { syslog(LOG_ERR, "aio: requested channel out of range"); return NULL; } diff --git a/src/gpio/gpio.c b/src/gpio/gpio.c index 8ae30fc..163cf79 100644 --- a/src/gpio/gpio.c +++ b/src/gpio/gpio.c @@ -145,7 +145,7 @@ mraa_gpio_init(int pin) pin = mraa_get_sub_platform_index(pin); } - if (pin < 0 || pin > board->phy_pin_count) { + if (pin < 0 || pin >= board->phy_pin_count) { syslog(LOG_ERR, "gpio: pin %i beyond platform definition", pin); return NULL; }