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)
This commit is contained in:
Luiz Otavio O Souza 2019-06-06 20:54:09 +00:00
parent 806adc6c00
commit e5b6bcc7d2

View File

@ -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]);