Source-Changes-HG archive

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

[src/netbsd-7]: src/sys Pull up following revision(s) (requested by maxv in t...



details:   https://anonhg.NetBSD.org/src/rev/9e658edf3cdb
branches:  netbsd-7
changeset: 799335:9e658edf3cdb
user:      snj <snj%NetBSD.org@localhost>
date:      Sat May 16 04:06:04 2015 +0000

description:
Pull up following revision(s) (requested by maxv in ticket #761):
        sys/arch/sgimips/dev/scn.c: revision 1.8
        sys/arch/sgimips/mace/macekbc.c: revision 1.8
        sys/dev/hpc/hpcfb.c: revision 1.59
        sys/dev/i2c/i2c.c: revision 1.47
        sys/dev/ic/mfi.c: revision 1.57
        sys/dev/if_ndis/if_ndis_pci.c: revision 1.21
        sys/dev/sysmon/sysmon_power.c: revisions 1.50-1.52
        sys/dev/usb/umass_isdata.c: revision 1.31
fix double free, found by Brainy.
--
Free cmd on error if we allocated it.
Found by Brainy, reported by maxv@.
--
don't leak rl (but there are other leaks), found by Brainy.
--
Free ped if we can't hand it to the power daemon.
Found by Brainy, reported by maxv@.
--
don't forget to free the dictionary.
--
another missing free dict.
--
fix leak, found by Brainy.
--
don't malloc a tiny, fixed size buffer to scribble into, then not use it
and never free it either
found by Brainy
--
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/dev/scn.c      |   8 ++------
 sys/arch/sgimips/mace/macekbc.c |  17 ++++++++++-------
 sys/dev/hpc/hpcfb.c             |  17 ++++++++++-------
 sys/dev/i2c/i2c.c               |   6 ++++--
 sys/dev/ic/mfi.c                |   8 +++-----
 sys/dev/if_ndis/if_ndis_pci.c   |  19 ++++++++++++-------
 sys/dev/sysmon/sysmon_power.c   |  10 ++++++++--
 sys/dev/usb/umass_isdata.c      |  11 +++++++----
 8 files changed, 56 insertions(+), 40 deletions(-)

diffs (truncated from 355 to 300 lines):

diff -r 8c16fcaa5191 -r 9e658edf3cdb sys/arch/sgimips/dev/scn.c
--- a/sys/arch/sgimips/dev/scn.c        Sat May 16 03:45:21 2015 +0000
+++ b/sys/arch/sgimips/dev/scn.c        Sat May 16 04:06:04 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: scn.c,v 1.7 2014/07/25 08:10:34 dholland Exp $ */
+/*     $NetBSD: scn.c,v 1.7.2.1 2015/05/16 04:06:04 snj Exp $ */
 
 /*
  * Resurrected from the old pc532 port 1/18/2009.
@@ -92,7 +92,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: scn.c,v 1.7 2014/07/25 08:10:34 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: scn.c,v 1.7.2.1 2015/05/16 04:06:04 snj Exp $");
 
 #include "opt_ddb.h"
 #include "opt_kgdb.h"
@@ -815,7 +815,6 @@
        u_char mr1, mr2;
        enum scntype scntype = SCNUNK;
        const char *duart_type = "Unknown";
-       char *intrname;
        bool console, first;
        devmajor_t major;
 
@@ -906,9 +905,6 @@
                ch_base[CH_MR] = mr2;
                splx(s);
 
-               intrname = malloc(sizeof("scnXX"), M_DEVBUF, M_NOWAIT);
-               snprintf(intrname, sizeof("scnXX"), "scn%d", unit);
-
                /*
                 * On IP6 the console chip is duart1. The keyboard/mouse
                 * is duart0. Each chip has two channels and the channels
diff -r 8c16fcaa5191 -r 9e658edf3cdb sys/arch/sgimips/mace/macekbc.c
--- a/sys/arch/sgimips/mace/macekbc.c   Sat May 16 03:45:21 2015 +0000
+++ b/sys/arch/sgimips/mace/macekbc.c   Sat May 16 04:06:04 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.7.12.1 2015/05/16 04:06:04 snj 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.7.12.1 2015/05/16 04:06:04 snj 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
diff -r 8c16fcaa5191 -r 9e658edf3cdb sys/dev/hpc/hpcfb.c
--- a/sys/dev/hpc/hpcfb.c       Sat May 16 03:45:21 2015 +0000
+++ b/sys/dev/hpc/hpcfb.c       Sat May 16 04:06:04 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.58.34.1 2015/05/16 04:06:04 snj 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.58.34.1 2015/05/16 04:06:04 snj 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 8c16fcaa5191 -r 9e658edf3cdb sys/dev/i2c/i2c.c
--- a/sys/dev/i2c/i2c.c Sat May 16 03:45:21 2015 +0000
+++ b/sys/dev/i2c/i2c.c Sat May 16 04:06:04 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: i2c.c,v 1.44.2.1 2015/01/23 09:50:36 martin Exp $      */
+/*     $NetBSD: i2c.c,v 1.44.2.2 2015/05/16 04:06:04 snj Exp $ */
 
 /*
  * Copyright (c) 2003 Wasabi Systems, Inc.
@@ -36,7 +36,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: i2c.c,v 1.44.2.1 2015/01/23 09:50:36 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: i2c.c,v 1.44.2.2 2015/05/16 04:06:04 snj Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -522,6 +522,8 @@
        if (iie->iie_buf != NULL && I2C_OP_WRITE_P(iie->iie_op)) {
                error = copyin(iie->iie_buf, buf, iie->iie_buflen);
                if (error) {
+                       if (cmd)
+                               kmem_free(cmd, iie->iie_cmdlen);
                        return error;
                }
        }
diff -r 8c16fcaa5191 -r 9e658edf3cdb sys/dev/ic/mfi.c
--- a/sys/dev/ic/mfi.c  Sat May 16 03:45:21 2015 +0000
+++ b/sys/dev/ic/mfi.c  Sat May 16 04:06:04 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: mfi.c,v 1.53.2.1 2014/08/22 10:41:18 martin Exp $ */
+/* $NetBSD: mfi.c,v 1.53.2.2 2015/05/16 04:06:04 snj Exp $ */
 /* $OpenBSD: mfi.c,v 1.66 2006/11/28 23:59:45 dlg Exp $ */
 
 /*
@@ -73,7 +73,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: mfi.c,v 1.53.2.1 2014/08/22 10:41:18 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: mfi.c,v 1.53.2.2 2015/05/16 04:06:04 snj Exp $");
 
 #include "bio.h"
 
@@ -3426,8 +3426,7 @@
 
        ld_size = sizeof(*ld_sync) * sc->sc_ld_list.mll_no_ld;
        
-       ld_sync = (struct mfi_ld *) malloc(ld_size, M_DEVBUF,
-            M_WAITOK | M_ZERO);
+       ld_sync = malloc(ld_size, M_DEVBUF, M_WAITOK | M_ZERO);
        if (ld_sync == NULL) {
                aprint_error_dev(sc->sc_dev, "Failed to allocate sync\n");
                goto err;
@@ -3438,7 +3437,6 @@
 
        if ((ccb = mfi_get_ccb(sc)) == NULL) {
                aprint_error_dev(sc->sc_dev, "Failed to get sync command\n");
-               free(ld_sync, M_DEVBUF);
                goto err;
        }
        sc->sc_ldsync_ccb = ccb;
diff -r 8c16fcaa5191 -r 9e658edf3cdb sys/dev/if_ndis/if_ndis_pci.c
--- a/sys/dev/if_ndis/if_ndis_pci.c     Sat May 16 03:45:21 2015 +0000
+++ b/sys/dev/if_ndis/if_ndis_pci.c     Sat May 16 04:06:04 2015 +0000
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_ndis_pci.c,v 1.19.12.1 2014/10/20 09:55:54 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_ndis_pci.c,v 1.19.12.2 2015/05/16 04:06:04 snj Exp $");
 #ifdef __FreeBSD__
 __FBSDID("$FreeBSD: src/sys/dev/if_ndis/if_ndis_pci.c,v 1.8.2.3 2005/03/31 04:24:36 wpaul Exp $");
 #endif
@@ -204,6 +204,7 @@
        int revision, i;
 #endif
        int bar;
+       size_t rllen;
        
        printf("in ndis_attach_pci()\n");
 
@@ -227,9 +228,9 @@
        
        printf("sc->ndis_mtag = %x\n", (unsigned int)sc->ndis_mtag);
 
-       rl = malloc(sizeof(ndis_resource_list) +
-           (sizeof(cm_partial_resource_desc) * (MAX_RESOURCES-1)),
-           M_DEVBUF, M_NOWAIT|M_ZERO);
+       rllen = sizeof(ndis_resource_list) +
+           sizeof(cm_partial_resource_desc) * (MAX_RESOURCES - 1);
+       rl = malloc(rllen, M_DEVBUF, M_NOWAIT|M_ZERO);
 
        if(rl == NULL) {
                sc->error = ENOMEM;
@@ -272,7 +273,7 @@
                                        malloc(sizeof(struct ndis_resource), M_DEVBUF, M_NOWAIT | M_ZERO)) == NULL) {
                                        //printf("error: out of memory\n");
                                        sc->error = ENOMEM;
-                                       return;
+                                       goto out;
                                }
                                sc->ndis_res_io->res_base = base;
                                sc->ndis_res_io->res_size = size;
@@ -293,7 +294,7 @@
                                        sc->ndis_res_altmem != NULL) {
                                        printf("too many resources\n");
                                        sc->error = ENXIO;
-                                       return;
+                                       goto out;
                                }
                                if(sc->ndis_res_mem) {
                                        if((sc->ndis_res_altmem = 
@@ -317,7 +318,7 @@
                                        if((sc->ndis_res_mem = 
                                                malloc(sizeof(struct ndis_resource), M_DEVBUF, M_NOWAIT | M_ZERO)) == NULL) {
                                                sc->error = ENOMEM;
-                                               return;
+                                               goto out;
                                        }
                                        sc->ndis_res_mem->res_base = base;
                                        sc->ndis_res_mem->res_size = size;
@@ -364,6 +365,10 @@
        
        kthread_create(PRI_NONE, 0, NULL, ndis_attach, (void *)sc,
            NULL, "ndis_attach");
+       return;
+out:
+       free(rl, M_DEVBUF); 
+       return;
 }
 
 
diff -r 8c16fcaa5191 -r 9e658edf3cdb sys/dev/sysmon/sysmon_power.c
--- a/sys/dev/sysmon/sysmon_power.c     Sat May 16 03:45:21 2015 +0000
+++ b/sys/dev/sysmon/sysmon_power.c     Sat May 16 04:06:04 2015 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sysmon_power.c,v 1.47.2.1 2015/01/12 21:15:12 snj Exp $        */
+/*     $NetBSD: sysmon_power.c,v 1.47.2.2 2015/05/16 04:06:05 snj Exp $        */
 
 /*-
  * Copyright (c) 2007 Juan Romero Pardines.
@@ -69,7 +69,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sysmon_power.c,v 1.47.2.1 2015/01/12 21:15:12 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysmon_power.c,v 1.47.2.2 2015/05/16 04:06:05 snj Exp $");



Home | Main Index | Thread Index | Old Index