From e5b6bcc7d2f4d1f791bac2ec6beb80f866d81c04 Mon Sep 17 00:00:00 2001 From: Luiz Otavio O Souza Date: Thu, 6 Jun 2019 20:54:09 +0000 Subject: [PATCH] Zero the GPIO regulator pins memory. This fixes a panic in Espressobin when gpioregulator fails to allocate the GPIO pin (the GPIO controller is not there). Sponsored by: Rubicon Communications, LLC (Netgate) --- sys/dev/gpio/gpioregulator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/dev/gpio/gpioregulator.c b/sys/dev/gpio/gpioregulator.c index 5c67a36909d..f3654542865 100644 --- a/sys/dev/gpio/gpioregulator.c +++ b/sys/dev/gpio/gpioregulator.c @@ -248,7 +248,7 @@ gpioregulator_parse_fdt(struct gpioregulator_softc *sc) /* "gpios" property */ sc->init_def.npins = 32 - __builtin_clz(mask); sc->init_def.pins = malloc(sc->init_def.npins * - sizeof(sc->init_def.pins), M_DEVBUF, M_WAITOK); + sizeof(sc->init_def.pins), M_DEVBUF, M_WAITOK | M_ZERO); for (n = 0; n < sc->init_def.npins; n++) { error = gpio_pin_get_by_ofw_idx(sc->dev, node, n, &sc->init_def.pins[n]);