summaryrefslogtreecommitdiff
path: root/sys/dev/acpi
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2016-05-08 09:30:24 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2016-05-08 09:30:24 +0000
commitcfcaa5eb3aa24b9f52f5b5200be759b50982460a (patch)
treed0727e2365c18666b1656551e3c163e6c467bee7 /sys/dev/acpi
parentdd82ddfc11feb4772979ba7da00bb21a99cbcae0 (diff)
Plug some memory leaks and do proper cleanup in error paths.
Diffstat (limited to 'sys/dev/acpi')
-rw-r--r--sys/dev/acpi/bytgpio.c11
-rw-r--r--sys/dev/acpi/chvgpio.c11
2 files changed, 13 insertions, 9 deletions
diff --git a/sys/dev/acpi/bytgpio.c b/sys/dev/acpi/bytgpio.c
index ec38f909f07..5b43e3b5902 100644
--- a/sys/dev/acpi/bytgpio.c
+++ b/sys/dev/acpi/bytgpio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: bytgpio.c,v 1.9 2016/05/07 18:08:27 kettenis Exp $ */
+/* $OpenBSD: bytgpio.c,v 1.10 2016/05/08 09:30:23 kettenis Exp $ */
/*
* Copyright (c) 2016 Mark Kettenis
*
@@ -170,6 +170,7 @@ bytgpio_attach(struct device *parent, struct device *self, void *aux)
printf("\n");
return;
}
+ aml_freevalue(&res);
sc->sc_pin_ih = mallocarray(sc->sc_npins, sizeof(*sc->sc_pin_ih),
M_DEVBUF, M_NOWAIT | M_ZERO);
@@ -184,14 +185,14 @@ bytgpio_attach(struct device *parent, struct device *self, void *aux)
if (bus_space_map(sc->sc_memt, sc->sc_addr, sc->sc_size, 0,
&sc->sc_memh)) {
printf(", can't map registers\n");
- goto fail;
+ goto free;
}
sc->sc_ih = acpi_intr_establish(sc->sc_irq, sc->sc_irq_flags, IPL_BIO,
bytgpio_intr, sc, sc->sc_dev.dv_xname);
if (sc->sc_ih == NULL) {
printf(", can't establish interrupt\n");
- goto fail;
+ goto unmap;
}
sc->sc_gpio.cookie = sc;
@@ -228,7 +229,9 @@ bytgpio_attach(struct device *parent, struct device *self, void *aux)
return;
-fail:
+unmap:
+ bus_space_unmap(sc->sc_memt, sc->sc_memh, sc->sc_size);
+free:
free(sc->sc_pin_ih, M_DEVBUF, sc->sc_npins * sizeof(*sc->sc_pin_ih));
}
diff --git a/sys/dev/acpi/chvgpio.c b/sys/dev/acpi/chvgpio.c
index 17267128b17..f3135584873 100644
--- a/sys/dev/acpi/chvgpio.c
+++ b/sys/dev/acpi/chvgpio.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: chvgpio.c,v 1.1 2016/05/07 23:10:50 kettenis Exp $ */
+/* $OpenBSD: chvgpio.c,v 1.2 2016/05/08 09:30:23 kettenis Exp $ */
/*
* Copyright (c) 2016 Mark Kettenis
*
@@ -209,6 +209,7 @@ chvgpio_attach(struct device *parent, struct device *self, void *aux)
printf("\n");
return;
}
+ aml_freevalue(&res);
printf(" irq %d", sc->sc_irq);
@@ -216,14 +217,14 @@ chvgpio_attach(struct device *parent, struct device *self, void *aux)
if (bus_space_map(sc->sc_memt, sc->sc_addr, sc->sc_size, 0,
&sc->sc_memh)) {
printf(", can't map registers\n");
- goto fail;
+ return;
}
sc->sc_ih = acpi_intr_establish(sc->sc_irq, sc->sc_irq_flags, IPL_BIO,
chvgpio_intr, sc, sc->sc_dev.dv_xname);
if (sc->sc_ih == NULL) {
printf(", can't establish interrupt\n");
- goto fail;
+ goto unmap;
}
sc->sc_gpio.cookie = sc;
@@ -240,8 +241,8 @@ chvgpio_attach(struct device *parent, struct device *self, void *aux)
printf(", %d pins\n", sc->sc_npins);
return;
-fail:
- free(sc->sc_pin_ih, M_DEVBUF, sc->sc_npins * sizeof(*sc->sc_pin_ih));
+unmap:
+ bus_space_unmap(sc->sc_memt, sc->sc_memh, sc->sc_size);
}
int