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.
This commit is contained in:
Jake Burkholder 2002-02-23 04:31:30 +00:00
parent 0c7065ad98
commit c2ef11f244
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=91112

View file

@ -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);
@ -213,6 +218,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;