Source-Changes-HG archive

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

[src/trunk]: src/sys/arch/sparc64/dev Make sure prom_getprop is called with t...



details:   https://anonhg.NetBSD.org/src/rev/ff742187c098
branches:  trunk
changeset: 559634:ff742187c098
user:      martin <martin%NetBSD.org@localhost>
date:      Sun Mar 21 12:50:14 2004 +0000

description:
Make sure prom_getprop is called with the size pointed to by nitem
initialized. (Some of these are more paranoia, but two were actual bugs.)
Print error codes in some panic messages.

diffstat:

 sys/arch/sparc64/dev/ebus.c   |  10 +++++++---
 sys/arch/sparc64/dev/psycho.c |  14 +++++++++-----
 sys/arch/sparc64/dev/sbus.c   |   5 +++--
 3 files changed, 19 insertions(+), 10 deletions(-)

diffs (124 lines):

diff -r 8371fa83a834 -r ff742187c098 sys/arch/sparc64/dev/ebus.c
--- a/sys/arch/sparc64/dev/ebus.c       Sun Mar 21 12:46:57 2004 +0000
+++ b/sys/arch/sparc64/dev/ebus.c       Sun Mar 21 12:50:14 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ebus.c,v 1.43 2004/03/17 17:04:59 pk Exp $     */
+/*     $NetBSD: ebus.c,v 1.44 2004/03/21 12:50:14 martin Exp $ */
 
 /*
  * Copyright (c) 1999, 2000, 2001 Matthew R. Green
@@ -29,7 +29,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ebus.c,v 1.43 2004/03/17 17:04:59 pk Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ebus.c,v 1.44 2004/03/21 12:50:14 martin Exp $");
 
 #include "opt_ddb.h"
 
@@ -198,17 +198,20 @@
         */
        sc->sc_intmap = NULL;
        sc->sc_range = NULL;
+       sc->sc_nintmap = 0;
        error = prom_getprop(node, "interrupt-map",
                        sizeof(struct ebus_interrupt_map),
                        &sc->sc_nintmap, &sc->sc_intmap);
        switch (error) {
        case 0:
                immp = &sc->sc_intmapmask;
+               nmapmask = sizeof(*immp);
                error = prom_getprop(node, "interrupt-map-mask",
                            sizeof(struct ebus_interrupt_map_mask), &nmapmask,
                            &immp);
                if (error)
-                       panic("could not get ebus interrupt-map-mask");
+                       panic("could not get ebus interrupt-map-mask, error %d",
+                           error);
                if (nmapmask != 1)
                        panic("ebus interrupt-map-mask is broken");
                break;
@@ -252,6 +255,7 @@
        int     n, rv;
 
        memset(ea, 0, sizeof(struct ebus_attach_args));
+       n = 0;
        rv = prom_getprop(node, "name", 1, &n, &ea->ea_name);
        if (rv != 0)
                return (rv);
diff -r 8371fa83a834 -r ff742187c098 sys/arch/sparc64/dev/psycho.c
--- a/sys/arch/sparc64/dev/psycho.c     Sun Mar 21 12:46:57 2004 +0000
+++ b/sys/arch/sparc64/dev/psycho.c     Sun Mar 21 12:50:14 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: psycho.c,v 1.69 2004/03/17 17:04:59 pk Exp $   */
+/*     $NetBSD: psycho.c,v 1.70 2004/03/21 12:50:14 martin Exp $       */
 
 /*
  * Copyright (c) 2001, 2002 Eduardo E. Horvath
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: psycho.c,v 1.69 2004/03/17 17:04:59 pk Exp $");
+__KERNEL_RCSID(0, "$NetBSD: psycho.c,v 1.70 2004/03/21 12:50:14 martin Exp $");
 
 #include "opt_ddb.h"
 
@@ -760,6 +760,7 @@
        bsize = BUS_ADDR(pr->size_hi, pr->size_lo);
 
        /* get available lists */
+       num = 0;
        if (prom_getprop(node, "available", sizeof(*pa), &num, &pa)) {
                printf("psycho_alloc_extent: prom_getprop failed\n");
                return NULL;
@@ -819,10 +820,12 @@
        int node;
        int *brp;
 {
-       int n;
+       int n, error;
 
-       if (prom_getprop(node, "bus-range", sizeof(*brp), &n, &brp))
-               panic("could not get psycho bus-range");
+       n = 2*sizeof(int);
+       error = prom_getprop(node, "bus-range", sizeof(*brp), &n, &brp);
+       if (error)
+               panic("could not get psycho bus-range, error %d", error);
        if (n != 2)
                panic("broken psycho bus-range");
        DPRINTF(PDB_PROM, ("psycho debug: got `bus-range' for node %08x: %u - %u\n",
@@ -992,6 +995,7 @@
         * We could query the `#virtual-dma-size-cells' and
         * `#virtual-dma-addr-cells' and DTRT, but I'm lazy.
         */
+       nitem = 0;
        if (!prom_getprop(sc->sc_node, "virtual-dma", sizeof(vdma), &nitem, 
                &vdma)) {
                /* Damn.  Gotta use these values. */
diff -r 8371fa83a834 -r ff742187c098 sys/arch/sparc64/dev/sbus.c
--- a/sys/arch/sparc64/dev/sbus.c       Sun Mar 21 12:46:57 2004 +0000
+++ b/sys/arch/sparc64/dev/sbus.c       Sun Mar 21 12:50:14 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sbus.c,v 1.67 2004/03/17 17:04:59 pk Exp $ */
+/*     $NetBSD: sbus.c,v 1.68 2004/03/21 12:50:14 martin Exp $ */
 
 /*
  * Copyright (c) 1999-2002 Eduardo Horvath
@@ -34,7 +34,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sbus.c,v 1.67 2004/03/17 17:04:59 pk Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sbus.c,v 1.68 2004/03/21 12:50:14 martin Exp $");
 
 #include "opt_ddb.h"
 
@@ -334,6 +334,7 @@
        int n;
 
        memset(sa, 0, sizeof(struct sbus_attach_args));
+       n = 0;
        error = prom_getprop(node, "name", 1, &n, &sa->sa_name);
        if (error != 0)
                return (error);



Home | Main Index | Thread Index | Old Index