devether: handle malloc error in etherprobe()
This commit is contained in:
parent
926dd18a7a
commit
6ac8a3ca65
1 changed files with 5 additions and 2 deletions
|
@ -380,6 +380,10 @@ etherprobe(int cardno, int ctlrno)
|
||||||
char buf[128], name[32];
|
char buf[128], name[32];
|
||||||
|
|
||||||
ether = malloc(sizeof(Ether));
|
ether = malloc(sizeof(Ether));
|
||||||
|
if(ether == nil){
|
||||||
|
print("etherprobe: no memory for Ether\n");
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
memset(ether, 0, sizeof(Ether));
|
memset(ether, 0, sizeof(Ether));
|
||||||
ether->ctlrno = ctlrno;
|
ether->ctlrno = ctlrno;
|
||||||
ether->tbdf = BUSUNKNOWN;
|
ether->tbdf = BUSUNKNOWN;
|
||||||
|
@ -460,8 +464,7 @@ etherprobe(int cardno, int ctlrno)
|
||||||
ether->limit = bsz;
|
ether->limit = bsz;
|
||||||
}
|
}
|
||||||
if(ether->oq == nil)
|
if(ether->oq == nil)
|
||||||
panic("etherreset %s: can't allocate output queue of %ld bytes",
|
panic("etherreset %s: can't allocate output queue of %ld bytes", name, bsz);
|
||||||
name, bsz);
|
|
||||||
ether->alen = Eaddrlen;
|
ether->alen = Eaddrlen;
|
||||||
memmove(ether->addr, ether->ea, Eaddrlen);
|
memmove(ether->addr, ether->ea, Eaddrlen);
|
||||||
memset(ether->bcast, 0xFF, Eaddrlen);
|
memset(ether->bcast, 0xFF, Eaddrlen);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue