Source-Changes-HG archive

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

[src/trunk]: src/sys/dev fix leak, found by Brainy.



details:   https://anonhg.NetBSD.org/src/rev/34af3c4b8cb8
branches:  trunk
changeset: 807303:34af3c4b8cb8
user:      christos <christos%NetBSD.org@localhost>
date:      Sat Apr 04 15:33:36 2015 +0000

description:
fix leak, found by Brainy.

diffstat:

 sys/dev/hpc/hpcfb.c        |  17 ++++++++++-------
 sys/dev/usb/umass_isdata.c |  11 +++++++----
 2 files changed, 17 insertions(+), 11 deletions(-)

diffs (80 lines):

diff -r cd997d5a28b6 -r 34af3c4b8cb8 sys/dev/hpc/hpcfb.c
--- a/sys/dev/hpc/hpcfb.c       Sat Apr 04 15:31:17 2015 +0000
+++ b/sys/dev/hpc/hpcfb.c       Sat Apr 04 15:33:36 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: hpcfb.c,v 1.58 2010/11/13 13:51:59 uebayasi Exp $      */
+/*     $NetBSD: hpcfb.c,v 1.59 2015/04/04 15:39:40 christos Exp $      */
 
 /*-
  * Copyright (c) 1999
@@ -43,7 +43,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: hpcfb.c,v 1.58 2010/11/13 13:51:59 uebayasi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: hpcfb.c,v 1.59 2015/04/04 15:39:40 christos Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_hpcfb.h"
@@ -472,7 +472,8 @@
        }
 
        if (rasops_init(ri, HPCFB_MAX_ROW, HPCFB_MAX_COLUMN)) {
-               panic("%s(%d): rasops_init() failed!", __FILE__, __LINE__);
+               aprint_error_dev(dc->dc_sc->sc_dev, "rasops_init() failed!")
+               return -1;
        }
 
        /* over write color map of rasops */
@@ -722,13 +723,15 @@
 
        DPRINTF(("%s(%d): hpcfb_alloc_screen()\n", __FILE__, __LINE__));
 
-       dc = malloc(sizeof(struct hpcfb_devconfig), M_DEVBUF, M_WAITOK|M_ZERO);
+       dc = malloc(sizeof(*dc), M_DEVBUF, M_WAITOK|M_ZERO);
        if (dc == NULL)
-               return (ENOMEM);
+               return ENOMEM;
 
        dc->dc_sc = sc;
-       if (hpcfb_init(&sc->sc_fbconflist[0], dc) != 0)
-               return (EINVAL);
+       if (hpcfb_init(&sc->sc_fbconflist[0], dc) != 0) {
+               free(dc, M_DEVBUF);
+               return EINVAL;
+       }
        if (sc->sc_accessops->font) {
                sc->sc_accessops->font(sc->sc_accessctx,
                    dc->dc_rinfo.ri_font);
diff -r cd997d5a28b6 -r 34af3c4b8cb8 sys/dev/usb/umass_isdata.c
--- a/sys/dev/usb/umass_isdata.c        Sat Apr 04 15:31:17 2015 +0000
+++ b/sys/dev/usb/umass_isdata.c        Sat Apr 04 15:33:36 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: umass_isdata.c,v 1.30 2014/09/12 16:40:38 skrll Exp $  */
+/*     $NetBSD: umass_isdata.c,v 1.31 2015/04/04 15:33:36 christos Exp $       */
 
 /*
  * TODO:
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: umass_isdata.c,v 1.30 2014/09/12 16:40:38 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umass_isdata.c,v 1.31 2015/04/04 15:33:36 christos Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -195,8 +195,11 @@
        USETW(req.wLength, sizeof *cf);
 
        err = usbd_do_request(sc->sc_udev, &req, cf);
-       if (err)
-               return (EIO);
+       if (err) {
+               sc->bus = NULL;
+               free(scbus, M_DEVBUF);
+               return EIO;
+       }
        DPRINTF(("umass_wd_attach info:\n  EventNotification=0x%02x "
                 "ExternalClock=0x%02x ATAInitTimeout=0x%02x\n"
                 "  ATAMisc1=0x%02x ATAMajorCommand=0x%02x "



Home | Main Index | Thread Index | Old Index