Source-Changes-HG archive

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

[src/trunk]: src/sys/arch fix leak



details:   https://anonhg.NetBSD.org/src/rev/fcd19e304b73
branches:  trunk
changeset: 332448:fcd19e304b73
user:      christos <christos%NetBSD.org@localhost>
date:      Sun Sep 21 16:37:34 2014 +0000

description:
fix leak

diffstat:

 sys/arch/sparc64/dev/psycho.c      |  8 ++++----
 sys/arch/sparc64/dev/schizo.c      |  5 +++--
 sys/arch/sparc64/sparc64/machdep.c |  8 +++++---
 sys/arch/sun68k/sun68k/bus.c       |  8 +++++---
 4 files changed, 17 insertions(+), 12 deletions(-)

diffs (122 lines):

diff -r 4909defddc99 -r fcd19e304b73 sys/arch/sparc64/dev/psycho.c
--- a/sys/arch/sparc64/dev/psycho.c     Sun Sep 21 16:36:32 2014 +0000
+++ b/sys/arch/sparc64/dev/psycho.c     Sun Sep 21 16:37:34 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: psycho.c,v 1.118 2013/12/07 11:17:24 nakayama Exp $    */
+/*     $NetBSD: psycho.c,v 1.119 2014/09/21 16:39:12 christos Exp $    */
 
 /*
  * Copyright (c) 1999, 2000 Matthew R. Green
@@ -55,7 +55,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: psycho.c,v 1.118 2013/12/07 11:17:24 nakayama Exp $");
+__KERNEL_RCSID(0, "$NetBSD: psycho.c,v 1.119 2014/09/21 16:39:12 christos Exp $");
 
 #include "opt_ddb.h"
 
@@ -1272,8 +1272,7 @@
        int ino;
        long vec = INTVEC(ihandle);
 
-       ih = (struct intrhand *)
-               malloc(sizeof(struct intrhand), M_DEVBUF, M_NOWAIT);
+       ih = malloc(sizeof(struct intrhand), M_DEVBUF, M_NOWAIT);
        if (ih == NULL)
                return (NULL);
 
@@ -1342,6 +1341,7 @@
        }
 
        printf("Cannot find interrupt vector %lx\n", vec);
+       free(ih, M_DEVBUF);
        return (NULL);
 
 found:
diff -r 4909defddc99 -r fcd19e304b73 sys/arch/sparc64/dev/schizo.c
--- a/sys/arch/sparc64/dev/schizo.c     Sun Sep 21 16:36:32 2014 +0000
+++ b/sys/arch/sparc64/dev/schizo.c     Sun Sep 21 16:37:34 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: schizo.c,v 1.31 2013/06/21 20:09:58 nakayama Exp $     */
+/*     $NetBSD: schizo.c,v 1.32 2014/09/21 16:39:12 christos Exp $     */
 /*     $OpenBSD: schizo.c,v 1.55 2008/08/18 20:29:37 brad Exp $        */
 
 /*
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: schizo.c,v 1.31 2013/06/21 20:09:58 nakayama Exp $");
+__KERNEL_RCSID(0, "$NetBSD: schizo.c,v 1.32 2014/09/21 16:39:12 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/device.h>
@@ -195,6 +195,7 @@
                          ma->ma_reg[0].ur_len,
                          BUS_SPACE_MAP_LINEAR, &pbm->sp_intrh)) {
                aprint_error(": failed to interrupt map registers\n");
+               kmem_free(pbm, sizeof(*pbm));
                return;
        }
 
diff -r 4909defddc99 -r fcd19e304b73 sys/arch/sparc64/sparc64/machdep.c
--- a/sys/arch/sparc64/sparc64/machdep.c        Sun Sep 21 16:36:32 2014 +0000
+++ b/sys/arch/sparc64/sparc64/machdep.c        Sun Sep 21 16:37:34 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: machdep.c,v 1.278 2014/07/14 12:40:38 nakayama Exp $ */
+/*     $NetBSD: machdep.c,v 1.279 2014/09/21 16:37:34 christos Exp $ */
 
 /*-
  * Copyright (c) 1996, 1997, 1998 The NetBSD Foundation, Inc.
@@ -71,7 +71,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.278 2014/07/14 12:40:38 nakayama Exp $");
+__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.279 2014/09/21 16:37:34 christos Exp $");
 
 #include "opt_ddb.h"
 #include "opt_multiprocessor.h"
@@ -1437,8 +1437,10 @@
         */
        error = uvm_pglistalloc(size, low, high,
            alignment, boundary, pglist, nsegs, (flags & BUS_DMA_NOWAIT) == 0);
-       if (error)
+       if (error) {
+               free(pglist, M_DEVBUF);
                return (error);
+       }
 
        /*
         * Compute the location, size, and number of segments actually
diff -r 4909defddc99 -r fcd19e304b73 sys/arch/sun68k/sun68k/bus.c
--- a/sys/arch/sun68k/sun68k/bus.c      Sun Sep 21 16:36:32 2014 +0000
+++ b/sys/arch/sun68k/sun68k/bus.c      Sun Sep 21 16:37:34 2014 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bus.c,v 1.21 2008/06/04 12:41:41 ad Exp $      */
+/*     $NetBSD: bus.c,v 1.22 2014/09/21 16:40:10 christos Exp $        */
 
 /*
  * Copyright (c) 1982, 1986, 1990, 1993
@@ -153,7 +153,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: bus.c,v 1.21 2008/06/04 12:41:41 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: bus.c,v 1.22 2014/09/21 16:40:10 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -266,8 +266,10 @@
         */
        error = uvm_pglistalloc(size, low, high, 0, 0,
                                mlist, nsegs, (flags & BUS_DMA_NOWAIT) == 0);
-       if (error)
+       if (error) {
+               free(mlist, M_DEVBUF);
                return (error);
+       }
 
        /*
         * Simply keep a pointer around to the linked list, so



Home | Main Index | Thread Index | Old Index