Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/sgimips/mace malloc() -> kmem_alloc() for private d...



details:   https://anonhg.NetBSD.org/src/rev/aa95fbdbf99f
branches:  trunk
changeset: 337150:aa95fbdbf99f
user:      macallan <macallan%NetBSD.org@localhost>
date:      Sat Apr 04 14:19:00 2015 +0000

description:
malloc() -> kmem_alloc() for private data, also kmem_free() them if we
don't finish attaching for whatever reason

found by Brainy

diffstat:

 sys/arch/sgimips/mace/macekbc.c |  17 ++++++++++-------
 1 files changed, 10 insertions(+), 7 deletions(-)

diffs (67 lines):

diff -r 9709c49f28da -r aa95fbdbf99f sys/arch/sgimips/mace/macekbc.c
--- a/sys/arch/sgimips/mace/macekbc.c   Sat Apr 04 14:12:40 2015 +0000
+++ b/sys/arch/sgimips/mace/macekbc.c   Sat Apr 04 14:19:00 2015 +0000
@@ -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 <jmcneill%invisible.ca@localhost>
@@ -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 @@
        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 @@
            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 @@
                t->t_present[PCKBPORT_AUX_SLOT] = 1;
 
        return;
+bork:
+       kmem_free(t, sizeof(struct macekbc_internal));
+       return;
 }
 
 static int



Home | Main Index | Thread Index | Old Index