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 ebus_find_node(): plug memory leak; mak...



details:   https://anonhg.NetBSD.org/src/rev/13d98814c3ff
branches:  trunk
changeset: 501894:13d98814c3ff
user:      pk <pk%NetBSD.org@localhost>
date:      Mon Jan 08 22:15:47 2001 +0000

description:
ebus_find_node(): plug memory leak; make debug output meaningfuller.

diffstat:

 sys/arch/sparc64/dev/ebus.c |  17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)

diffs (53 lines):

diff -r 08510dcfe18e -r 13d98814c3ff sys/arch/sparc64/dev/ebus.c
--- a/sys/arch/sparc64/dev/ebus.c       Mon Jan 08 22:12:57 2001 +0000
+++ b/sys/arch/sparc64/dev/ebus.c       Mon Jan 08 22:15:47 2001 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ebus.c,v 1.18 2000/12/04 16:01:18 fvdl Exp $   */
+/*     $NetBSD: ebus.c,v 1.19 2001/01/08 22:15:47 pk Exp $     */
 
 /*
  * Copyright (c) 1999, 2000 Matthew R. Green
@@ -361,18 +361,19 @@
        int pcibus, bus, dev, fn;
 
        DPRINTF(EDB_PROM, ("ebus_find_node: looking at pci node %08x\n", node));
+
+       /* pull the PCI bus out of the pa_tag */
+       pcibus = (pa->pa_tag >> 16) & 0xff;
+       DPRINTF(EDB_PROM, ("; pcibus %d dev %d fn %d\n", pcibus, pa->pa_device, pa->pa_function));
+
        for (node = firstchild(node); node; node = nextsibling(node)) {
                char *name = getpropstring(node, "name");
 
-               DPRINTF(EDB_PROM, ("ebus_find_node: looking at PCI device `%s', node = %08x\n", name, node));
+               DPRINTF(EDB_PROM, ("; looking at PCI device `%s', node = %08x\n", name, node));
                /* must be "ebus" */
                if (strcmp(name, "ebus") != 0)
                        continue;
 
-               /* pull the PCI bus out of the pa_tag */
-               pcibus = (pa->pa_tag >> 16) & 0xff;
-               DPRINTF(EDB_PROM, ("; pcibus %d dev %d fn %d\n", pcibus, pa->pa_device, pa->pa_function));
-
                /* get the PCI bus/device/function for this node */
                ap = NULL;
                if (getprop(node, "reg", sizeof(int), &n,
@@ -382,8 +383,9 @@
                bus = (ap[0] >> 16) & 0xff;
                dev = (ap[0] >> 11) & 0x1f;
                fn = (ap[0] >> 8) & 0x7;
+               free(ap, M_DEVBUF);
 
-               DPRINTF(EDB_PROM, ("; looking for bus %d dev %d fn %d\n", pcibus, pa->pa_device, pa->pa_function));
+               DPRINTF(EDB_PROM, ("; looking at ebus node: bus %d dev %d fn %d\n", bus, dev, fn));
                if (pa->pa_device != dev ||
                    pa->pa_function != fn ||
                    pcibus != bus)
@@ -391,7 +393,6 @@
 
                DPRINTF(EDB_PROM, ("; found it, returning %08x\n", node));
                /* found it! */
-               free(ap, M_DEVBUF);
                return (node);
        }
 



Home | Main Index | Thread Index | Old Index