Module Name: src
Committed By: macallan
Date: Sat Apr 4 14:19:00 UTC 2015
Modified Files:
src/sys/arch/sgimips/mace: macekbc.c
Log Message:
malloc() -> kmem_alloc() for private data, also kmem_free() them if we
don't finish attaching for whatever reason
found by Brainy
To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/sgimips/mace/macekbc.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/arch/sgimips/mace/macekbc.c
diff -u src/sys/arch/sgimips/mace/macekbc.c:1.7 src/sys/arch/sgimips/mace/macekbc.c:1.8
--- src/sys/arch/sgimips/mace/macekbc.c:1.7 Sat Oct 27 17:18:10 2012
+++ src/sys/arch/sgimips/mace/macekbc.c Sat Apr 4 14:19:00 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: macekbc.c,v 1.7 2012/10/27 17:18:10 chs Exp $ */
+/* $NetBSD: macekbc.c,v 1.8 2015/04/04 14:19:00 macallan Exp $ */
/*-
* Copyright (c) 2007 Jared D. McNeill <[email protected]>
@@ -31,12 +31,12 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: macekbc.c,v 1.7 2012/10/27 17:18:10 chs Exp $");
+__KERNEL_RCSID(0, "$NetBSD: macekbc.c,v 1.8 2015/04/04 14:19:00 macallan Exp $");
#include <sys/param.h>
#include <sys/device.h>
#include <sys/syslog.h>
-#include <sys/malloc.h>
+#include <sys/kmem.h>
#include <sys/bus.h>
#include <machine/intr.h>
@@ -125,7 +125,7 @@ macekbc_attach(device_t parent, device_t
aprint_normal(": PS2 controller\n");
aprint_naive("\n");
- t = malloc(sizeof(struct macekbc_internal), M_DEVBUF, M_NOWAIT|M_ZERO);
+ t = kmem_alloc(sizeof(struct macekbc_internal), KM_NOSLEEP);
if (t == NULL) {
aprint_error("%s: not enough memory\n", device_xname(self));
return;
@@ -137,20 +137,20 @@ macekbc_attach(device_t parent, device_t
0, &t->t_ioh[PCKBPORT_KBD_SLOT]) != 0) {
aprint_error("%s: couldn't map kbd registers\n",
device_xname(self));
- return;
+ goto bork;
}
if (bus_space_subregion(t->t_iot, maa->maa_sh, maa->maa_offset + 32,
0, &t->t_ioh[PCKBPORT_AUX_SLOT]) != 0) {
aprint_error("%s: couldn't map aux registers\n",
device_xname(self));
- return;
+ goto bork;
}
if ((t->t_rxih = cpu_intr_establish(maa->maa_intr, maa->maa_intrmask,
macekbc_intr, t)) == NULL) {
printf("%s: couldn't establish interrupt\n",
device_xname(self));
- return;
+ goto bork;
}
sc->sc_id = t;
t->t_sc = sc;
@@ -169,6 +169,9 @@ macekbc_attach(device_t parent, device_t
t->t_present[PCKBPORT_AUX_SLOT] = 1;
return;
+bork:
+ kmem_free(t, sizeof(struct macekbc_internal));
+ return;
}
static int