diff options
author | jake <jake@FreeBSD.org> | 2002-02-23 04:31:30 +0000 |
---|---|---|
committer | jake <jake@FreeBSD.org> | 2002-02-23 04:31:30 +0000 |
commit | e187f56a069640f11e555f8d94bf6ffa723620b5 (patch) | |
tree | 4a1057a9da8065c3c8c5e78b01ff5310796c808f | |
parent | c819020411fe5f38e89112c32b0073e064bf1649 (diff) | |
download | FreeBSD-src-e187f56a069640f11e555f8d94bf6ffa723620b5.zip FreeBSD-src-e187f56a069640f11e555f8d94bf6ffa723620b5.tar.gz |
Check the return values of index() and don't dereference it if its null;
the path may not have a ':' in it. The mac address property is called
mac-address for sparc64. Don't allocate a dma buffer for sparc64 either.
-rw-r--r-- | sys/boot/ofw/libofw/ofw_net.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/sys/boot/ofw/libofw/ofw_net.c b/sys/boot/ofw/libofw/ofw_net.c index 712a457..e14759c 100644 --- a/sys/boot/ofw/libofw/ofw_net.c +++ b/sys/boot/ofw/libofw/ofw_net.c @@ -188,10 +188,14 @@ ofwn_init(struct iodesc *desc, void *machdep_hint) chosen = OF_finddevice("/chosen"); OF_getprop(chosen, "memory", &memory, sizeof(memory)); pathlen = OF_getprop(chosen, "bootpath", path, 64); - ch = index(path, ':'); - *ch = '\0'; + if ((ch = index(path, ':')) != NULL) + *ch = '\0'; netdev = OF_finddevice(path); +#ifdef __sparc64__ + if (OF_getprop(netdev, "mac-address", desc->myea, 6) == -1) +#else if (OF_getprop(netdev, "local-mac-address", desc->myea, 6) == -1) +#endif goto punt; printf("boot: ethernet address: %s\n", ether_sprintf(desc->myea)); @@ -205,6 +209,7 @@ ofwn_init(struct iodesc *desc, void *machdep_hint) printf("ofwn_init: OpenFirmware instance handle: %08x\n", netinstance); #endif +#ifndef __sparc64__ if (OF_call_method("dma-alloc", netinstance, 1, 1, NULL, &dmabuf) < 0) { printf("Failed to allocate DMA buffer (got %08x).\n", dmabuf); @@ -214,6 +219,7 @@ ofwn_init(struct iodesc *desc, void *machdep_hint) #if defined(NETIF_DEBUG) printf("ofwn_init: allocated DMA buffer: %08x\n", dmabuf); #endif +#endif return; |