summaryrefslogtreecommitdiff
path: root/sys/dev/fdt
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2020-04-25 22:15:01 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2020-04-25 22:15:01 +0000
commitdfdf8b325553b3466e2eee966fc7f4837d9f0088 (patch)
tree878a76ed4a010c917f8e54f9f799591b7a0a98a1 /sys/dev/fdt
parent7246a7edf1707c480bc0962437e48da40460eaed (diff)
Explicitly check that the length of the "brcm,pull" property is greater
than zero to avoid a null-pointer dereference caused by unexpected (at least by me) type promotion. ok patrick@
Diffstat (limited to 'sys/dev/fdt')
-rw-r--r--sys/dev/fdt/bcm2835_gpio.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/sys/dev/fdt/bcm2835_gpio.c b/sys/dev/fdt/bcm2835_gpio.c
index 4d9d0ab3426..aaa1a6015ee 100644
--- a/sys/dev/fdt/bcm2835_gpio.c
+++ b/sys/dev/fdt/bcm2835_gpio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bcm2835_gpio.c,v 1.1 2020/04/24 09:52:43 kettenis Exp $ */
+/* $OpenBSD: bcm2835_gpio.c,v 1.2 2020/04/25 22:15:00 kettenis Exp $ */
/*
* Copyright (c) 2020 Mark Kettenis <kettenis@openbsd.org>
*
@@ -118,7 +118,7 @@ bcmgpio_config_func(struct bcmgpio_softc *sc, int pin, int func)
int reg = (pin / 10);
int shift = (pin % 10) * 3;
uint32_t val;
-
+
val = HREAD4(sc, GPFSEL(reg));
val &= ~(GPFSEL_MASK << shift);
HWRITE4(sc, GPFSEL(reg), val);
@@ -184,7 +184,7 @@ bcmgpio_pinctrl(uint32_t phandle, void *cookie)
for (i = 0; i < len / sizeof(uint32_t); i++) {
bcmgpio_config_func(sc, pins[i], func);
- if (i < plen / sizeof(uint32_t))
+ if (plen > 0 && i < plen / sizeof(uint32_t))
sc->sc_config_pull(sc, pins[i], pull[i]);
}