summaryrefslogtreecommitdiff
path: root/sys/src/9/pc/ether2000.c
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@centraldogma>2011-12-12 22:24:25 +0100
committercinap_lenrek <cinap_lenrek@centraldogma>2011-12-12 22:24:25 +0100
commit9679d7525c205de90e9dcadcf6762b04114f8c45 (patch)
tree8681e308104e48eed2753c1b76eba1a8bac57341 /sys/src/9/pc/ether2000.c
parentf32ef135d4bce251f72275d30cfcd86cb188b8c9 (diff)
kernel: fix more malloc bugs
Diffstat (limited to 'sys/src/9/pc/ether2000.c')
-rw-r--r--sys/src/9/pc/ether2000.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/sys/src/9/pc/ether2000.c b/sys/src/9/pc/ether2000.c
index 8fc8911e1..7c5c25db7 100644
--- a/sys/src/9/pc/ether2000.c
+++ b/sys/src/9/pc/ether2000.c
@@ -98,8 +98,11 @@ ne2000pnp(Ether* edev)
if(p->ccrb != 0x02 || p->ccru != 0)
continue;
ctlr = malloc(sizeof(Ctlr));
+ if(ctlr == nil){
+ print("ne2000pnp: can't allocate memory\n");
+ continue;
+ }
ctlr->pcidev = p;
-
if(ctlrhead != nil)
ctlrtail->next = ctlr;
else
@@ -161,6 +164,11 @@ ne2000reset(Ether* edev)
return -1;
edev->ctlr = malloc(sizeof(Dp8390));
+ if(edev->ctlr == nil){
+ print("ne2000: can't allocate memory\n");
+ iofree(port);
+ return -1;
+ }
dp8390 = edev->ctlr;
dp8390->width = 2;
dp8390->ram = 0;
@@ -228,5 +236,5 @@ ne2000reset(Ether* edev)
void
ether2000link(void)
{
- addethercard("NE2000", ne2000reset);
+ addethercard("ne2000", ne2000reset);
}