Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/xen/xen replace malloc() with kmem_zalloc() per req...



details:   https://anonhg.NetBSD.org/src/rev/a192c7ade4da
branches:  trunk
changeset: 771905:a192c7ade4da
user:      cegger <cegger%NetBSD.org@localhost>
date:      Wed Dec 07 16:26:23 2011 +0000

description:
replace malloc() with kmem_zalloc() per request from cherry.
While here fix error path.

XXX: The size allocated and freed for interrupt handlers looks
inconsistent to me.

diffstat:

 sys/arch/xen/xen/evtchn.c |  12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)

diffs (45 lines):

diff -r 8dfcf7efbab8 -r a192c7ade4da sys/arch/xen/xen/evtchn.c
--- a/sys/arch/xen/xen/evtchn.c Wed Dec 07 16:10:59 2011 +0000
+++ b/sys/arch/xen/xen/evtchn.c Wed Dec 07 16:26:23 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: evtchn.c,v 1.59 2011/12/07 15:47:43 cegger Exp $       */
+/*     $NetBSD: evtchn.c,v 1.60 2011/12/07 16:26:23 cegger Exp $       */
 
 /*
  * Copyright (c) 2006 Manuel Bouyer.
@@ -54,7 +54,7 @@
 
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.59 2011/12/07 15:47:43 cegger Exp $");
+__KERNEL_RCSID(0, "$NetBSD: evtchn.c,v 1.60 2011/12/07 16:26:23 cegger Exp $");
 
 #include "opt_xen.h"
 #include "isa.h"
@@ -66,7 +66,6 @@
 #include <sys/systm.h>
 #include <sys/device.h>
 #include <sys/proc.h>
-#include <sys/malloc.h>
 #include <sys/kmem.h>
 #include <sys/reboot.h>
 #include <sys/mutex.h>
@@ -555,14 +554,15 @@
        struct pintrhand *ih;
        physdev_op_t physdev_op;
 
-       ih = malloc(sizeof *ih, M_DEVBUF, cold ? M_NOWAIT : M_WAITOK);
+       ih = kmem_zalloc(sizeof(struct pintrhand),
+           cold ? KM_NOSLEEP : KM_SLEEP);
        if (ih == NULL) {
-               printf("pirq_establish: can't malloc handler info\n");
+               printf("pirq_establish: can't allocate handler info\n");
                return NULL;
        }
 
        if (event_set_handler(evtch, pirq_interrupt, ih, level, evname) != 0) {
-               kmem_free(ih, sizeof (struct iplsource));
+               kmem_free(ih, sizeof(struct pintrhand));
                return NULL;
        }
 



Home | Main Index | Thread Index | Old Index