diff options
author | cinap_lenrek <cinap_lenrek@centraldogma> | 2011-12-12 22:24:25 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@centraldogma> | 2011-12-12 22:24:25 +0100 |
commit | 9679d7525c205de90e9dcadcf6762b04114f8c45 (patch) | |
tree | 8681e308104e48eed2753c1b76eba1a8bac57341 /sys/src/9/pc/ether82557.c | |
parent | f32ef135d4bce251f72275d30cfcd86cb188b8c9 (diff) |
kernel: fix more malloc bugs
Diffstat (limited to 'sys/src/9/pc/ether82557.c')
-rw-r--r-- | sys/src/9/pc/ether82557.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/sys/src/9/pc/ether82557.c b/sys/src/9/pc/ether82557.c index 6fbb12a72..8f5c9ebf1 100644 --- a/sys/src/9/pc/ether82557.c +++ b/sys/src/9/pc/ether82557.c @@ -795,6 +795,8 @@ ctlrinit(Ctlr* ctlr) */ ilock(&ctlr->cblock); ctlr->cbr = malloc(ctlr->ncb*sizeof(Cb)); + if(ctlr->cbr == nil) + panic("i82557: can't allocate cbr"); for(i = 0; i < ctlr->ncb; i++){ ctlr->cbr[i].status = CbC|CbOK; ctlr->cbr[i].command = CbS|CbNOP; @@ -911,6 +913,8 @@ reread: if(ctlr->eepromsz == 0){ ctlr->eepromsz = 8-size; ctlr->eeprom = malloc((1<<ctlr->eepromsz)*sizeof(ushort)); + if(ctlr->eeprom == nil) + panic("i82557: can't allocate eeprom"); goto reread; } @@ -971,6 +975,11 @@ i82557pci(void) } ctlr = malloc(sizeof(Ctlr)); + if(ctlr == nil){ + print("i82557: can't allocate memory\n"); + iofree(port); + continue; + } ctlr->port = port; ctlr->pcidev = p; ctlr->nop = nop; |