summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkettenis <kettenis@openbsd.org>2020-04-07 09:06:52 +0000
committerkettenis <kettenis@openbsd.org>2020-04-07 09:06:52 +0000
commit565062e8ce2354218164d796fc22162eeb58ef54 (patch)
tree297ead9f272b3c16379c9f0a66ea50c07bf0554c
parentRemove entry that is no longer needed. (diff)
downloadwireguard-openbsd-565062e8ce2354218164d796fc22162eeb58ef54.tar.xz
wireguard-openbsd-565062e8ce2354218164d796fc22162eeb58ef54.zip
Fix off-by-one in check for valid pin numbers and use the existing
#define in the check.
-rw-r--r--sys/dev/fdt/rkgpio.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/sys/dev/fdt/rkgpio.c b/sys/dev/fdt/rkgpio.c
index ba37340446c..536fc4e9bf5 100644
--- a/sys/dev/fdt/rkgpio.c
+++ b/sys/dev/fdt/rkgpio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: rkgpio.c,v 1.2 2019/05/11 14:56:12 patrick Exp $ */
+/* $OpenBSD: rkgpio.c,v 1.3 2020/04/07 09:06:52 kettenis Exp $ */
/*
* Copyright (c) 2017 Mark Kettenis <kettenis@openbsd.org>
* Copyright (c) 2019 Patrick Wildt <patrick@blueri.se>
@@ -159,7 +159,7 @@ rkgpio_config_pin(void *cookie, uint32_t *cells, int config)
struct rkgpio_softc *sc = cookie;
uint32_t pin = cells[0];
- if (pin > 32)
+ if (pin >= GPIO_NUM_PINS)
return;
if (config & GPIO_CONFIG_OUTPUT)
@@ -177,7 +177,7 @@ rkgpio_get_pin(void *cookie, uint32_t *cells)
uint32_t reg;
int val;
- if (pin > 32)
+ if (pin >= GPIO_NUM_PINS)
return 0;
reg = HREAD4(sc, GPIO_EXT_PORTA);
@@ -195,7 +195,7 @@ rkgpio_set_pin(void *cookie, uint32_t *cells, int val)
uint32_t pin = cells[0];
uint32_t flags = cells[1];
- if (pin > 32)
+ if (pin >= GPIO_NUM_PINS)
return;
if (flags & GPIO_ACTIVE_LOW)