summaryrefslogtreecommitdiff
path: root/sys/src/9/pc/ether2114x.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/ether2114x.c
parentf32ef135d4bce251f72275d30cfcd86cb188b8c9 (diff)
kernel: fix more malloc bugs
Diffstat (limited to 'sys/src/9/pc/ether2114x.c')
-rw-r--r--sys/src/9/pc/ether2114x.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/sys/src/9/pc/ether2114x.c b/sys/src/9/pc/ether2114x.c
index 290b4272f..4e1b6ebdc 100644
--- a/sys/src/9/pc/ether2114x.c
+++ b/sys/src/9/pc/ether2114x.c
@@ -1463,8 +1463,11 @@ srom(Ctlr* ctlr)
* Do a dummy read first to get the size and allocate ctlr->srom.
*/
sromr(ctlr, 0);
- if(ctlr->srom == nil)
+ if(ctlr->srom == nil){
ctlr->srom = malloc((1<<ctlr->sromsz)*sizeof(ushort));
+ if(ctlr->srom == nil)
+ panic("dec2114x: can't allocate srom");
+ }
for(i = 0; i < (1<<ctlr->sromsz); i++){
x = sromr(ctlr, i);
ctlr->srom[2*i] = x;
@@ -1665,6 +1668,10 @@ dec2114xpci(void)
* bar[1] is the memory-mapped register address.
*/
ctlr = malloc(sizeof(Ctlr));
+ if(ctlr == nil){
+ print("dec2114x: can't allocate memory\n");
+ continue;
+ }
ctlr->port = p->mem[0].bar & ~0x01;
ctlr->pcidev = p;
ctlr->id = (p->did<<16)|p->vid;