diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2016-06-11 21:30:19 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2016-06-13 15:34:23 -0400 |
commit | e4859d2e9a9de74734519d0c1e01c7e0d18e7bc9 (patch) | |
tree | c518de43eaab78bfab5aa1103d0300140a6654db /src | |
parent | 91e7807af61ba8a907f7eca8952efcb91ec81935 (diff) | |
download | kutter-e4859d2e9a9de74734519d0c1e01c7e0d18e7bc9.tar.gz kutter-e4859d2e9a9de74734519d0c1e01c7e0d18e7bc9.tar.xz kutter-e4859d2e9a9de74734519d0c1e01c7e0d18e7bc9.zip |
gpio: Fix off-by-one bug in check for the maximum gpio port
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src')
-rw-r--r-- | src/avr/gpio.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/avr/gpio.c b/src/avr/gpio.c index 4ec1e316..9f947e7a 100644 --- a/src/avr/gpio.c +++ b/src/avr/gpio.c @@ -137,7 +137,7 @@ static const uint8_t ADMUX_DEFAULT = 0x40; struct gpio_out gpio_out_setup(uint8_t pin, uint8_t val) { - if (GPIO2PORT(pin) > ARRAY_SIZE(digital_regs)) + if (GPIO2PORT(pin) >= ARRAY_SIZE(digital_regs)) goto fail; struct gpio_digital_regs *regs = GPIO2REGS(pin); if (! regs) @@ -168,7 +168,7 @@ gpio_out_write(struct gpio_out g, uint8_t val) struct gpio_in gpio_in_setup(uint8_t pin, int8_t pull_up) { - if (GPIO2PORT(pin) > ARRAY_SIZE(digital_regs)) + if (GPIO2PORT(pin) >= ARRAY_SIZE(digital_regs)) goto fail; struct gpio_digital_regs *regs = GPIO2REGS(pin); if (! regs) |