summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@centraldogma>2011-12-12 16:55:26 +0100
committercinap_lenrek <cinap_lenrek@centraldogma>2011-12-12 16:55:26 +0100
commitbf3476d661e05208b78f70cdaa5656ff77264d23 (patch)
treef5c52910b93aa74586740a54f6b2911e95ae96cc
parent589f99915eb95d9207c08259c8880675a0a502cf (diff)
kernel: fix inproper use of malloc/smalloc
-rw-r--r--sys/src/9/pc/devarch.c2
-rw-r--r--sys/src/9/pc/devi82365.c2
-rw-r--r--sys/src/9/pc/devpccard.c2
-rw-r--r--sys/src/9/pc/devvga.c2
-rw-r--r--sys/src/9/pc/ether2114x.c2
-rw-r--r--sys/src/9/pc/ether79c970.c2
-rw-r--r--sys/src/9/pc/ether8139.c2
-rw-r--r--sys/src/9/pc/ether8169.c7
-rw-r--r--sys/src/9/pc/ether82543gc.c3
-rw-r--r--sys/src/9/pc/ether82557.c2
-rw-r--r--sys/src/9/pc/ether82563.c5
-rw-r--r--sys/src/9/pc/ether82598.c4
-rw-r--r--sys/src/9/pc/ether83815.c2
-rw-r--r--sys/src/9/pc/etherdp83820.c2
-rw-r--r--sys/src/9/pc/etherelnk3.c2
-rw-r--r--sys/src/9/pc/etherga620.c6
-rw-r--r--sys/src/9/pc/etherigbe.c8
-rw-r--r--sys/src/9/pc/etherm10g.c8
-rw-r--r--sys/src/9/pc/ethersmc.c2
-rw-r--r--sys/src/9/pc/ethervgbe.c5
-rw-r--r--sys/src/9/pc/ethervt6102.c2
-rw-r--r--sys/src/9/pc/main.c2
-rw-r--r--sys/src/9/pc/mmu.c2
-rw-r--r--sys/src/9/pc/mp.c2
-rw-r--r--sys/src/9/pc/piix4smbus.c4
-rw-r--r--sys/src/9/pc/sdodin.c8
-rw-r--r--sys/src/9/pc/uartaxp.c2
-rw-r--r--sys/src/9/pc/uarti8250.c2
-rw-r--r--sys/src/9/pc/usbehcipc.c6
-rw-r--r--sys/src/9/pc/usbohci.c12
-rw-r--r--sys/src/9/pc/usbuhci.c9
-rw-r--r--sys/src/9/pc/wavelan.c4
-rw-r--r--sys/src/9/port/devuart.c2
-rw-r--r--sys/src/9/port/portclock.c4
34 files changed, 80 insertions, 51 deletions
diff --git a/sys/src/9/pc/devarch.c b/sys/src/9/pc/devarch.c
index 081607fe3..c68fc4d1a 100644
--- a/sys/src/9/pc/devarch.c
+++ b/sys/src/9/pc/devarch.c
@@ -871,7 +871,7 @@ archctlread(Chan*, void *a, long nn, vlong offset)
int n;
char *buf, *p, *ep;
- p = buf = malloc(READSTR);
+ p = buf = smalloc(READSTR);
ep = p + READSTR;
p = seprint(p, ep, "cpu %s %lud%s\n",
cputype->name, (ulong)(m->cpuhz+999999)/1000000,
diff --git a/sys/src/9/pc/devi82365.c b/sys/src/9/pc/devi82365.c
index 6a34e19be..8cdb6ef0f 100644
--- a/sys/src/9/pc/devi82365.c
+++ b/sys/src/9/pc/devi82365.c
@@ -765,7 +765,7 @@ i82365read(Chan *c, void *a, long n, vlong off)
case Qattr:
return pcmread(SLOTNO(c), TYPE(c) == Qattr, a, n, off);
case Qctl:
- buf = p = malloc(READSTR);
+ buf = p = smalloc(READSTR);
e = p + READSTR;
pp = slot + SLOTNO(c);
diff --git a/sys/src/9/pc/devpccard.c b/sys/src/9/pc/devpccard.c
index cd7321de9..8055cf9bc 100644
--- a/sys/src/9/pc/devpccard.c
+++ b/sys/src/9/pc/devpccard.c
@@ -1292,7 +1292,7 @@ pccardread(Chan *c, void *a, long n, vlong offset)
return devdirread(c, a, n, 0, 0, pccardgen);
case Qctl:
- buf = p = malloc(READSTR);
+ buf = p = smalloc(READSTR);
buf[0] = 0;
e = p + READSTR;
diff --git a/sys/src/9/pc/devvga.c b/sys/src/9/pc/devvga.c
index 10875f450..d9ddf9239 100644
--- a/sys/src/9/pc/devvga.c
+++ b/sys/src/9/pc/devvga.c
@@ -169,7 +169,7 @@ vgaread(Chan* c, void* a, long n, vlong off)
case Qvgactl:
scr = &vgascreen[0];
- p = malloc(READSTR);
+ p = smalloc(READSTR);
if(waserror()){
free(p);
nexterror();
diff --git a/sys/src/9/pc/ether2114x.c b/sys/src/9/pc/ether2114x.c
index 554ce7634..290b4272f 100644
--- a/sys/src/9/pc/ether2114x.c
+++ b/sys/src/9/pc/ether2114x.c
@@ -322,7 +322,7 @@ ifstat(Ether* ether, void* a, long n, ulong offset)
if(n == 0)
return 0;
- p = malloc(READSTR);
+ p = smalloc(READSTR);
l = snprint(p, READSTR, "Overflow: %lud\n", ctlr->of);
l += snprint(p+l, READSTR-l, "Ru: %lud\n", ctlr->ru);
l += snprint(p+l, READSTR-l, "Rps: %lud\n", ctlr->rps);
diff --git a/sys/src/9/pc/ether79c970.c b/sys/src/9/pc/ether79c970.c
index 5e682847d..ac1545364 100644
--- a/sys/src/9/pc/ether79c970.c
+++ b/sys/src/9/pc/ether79c970.c
@@ -204,7 +204,7 @@ ifstat(Ether* ether, void* a, long n, ulong offset)
if(n == 0)
return 0;
- p = malloc(READSTR);
+ p = smalloc(READSTR);
len = snprint(p, READSTR, "Rxbuff: %ld\n", ctlr->rxbuff);
len += snprint(p+len, READSTR-len, "Crc: %ld\n", ctlr->crc);
len += snprint(p+len, READSTR-len, "Oflo: %ld\n", ctlr->oflo);
diff --git a/sys/src/9/pc/ether8139.c b/sys/src/9/pc/ether8139.c
index 20f09cbd6..f304df603 100644
--- a/sys/src/9/pc/ether8139.c
+++ b/sys/src/9/pc/ether8139.c
@@ -310,7 +310,7 @@ rtl8139ifstat(Ether* edev, void* a, long n, ulong offset)
Ctlr *ctlr;
ctlr = edev->ctlr;
- p = malloc(READSTR);
+ p = smalloc(READSTR);
l = snprint(p, READSTR, "rcr %#8.8ux\n", ctlr->rcr);
l += snprint(p+l, READSTR-l, "multicast %ud\n", ctlr->mcast);
l += snprint(p+l, READSTR-l, "ierrs %d\n", ctlr->ierrs);
diff --git a/sys/src/9/pc/ether8169.c b/sys/src/9/pc/ether8169.c
index dc7f104d1..020fd69d1 100644
--- a/sys/src/9/pc/ether8169.c
+++ b/sys/src/9/pc/ether8169.c
@@ -494,10 +494,11 @@ rtl8169ifstat(Ether* edev, void* a, long n, ulong offset)
Dtcc *dtcc;
int i, l, r, timeo;
+ p = smalloc(READSTR);
+
ctlr = edev->ctlr;
qlock(&ctlr->slock);
- p = nil;
if(waserror()){
qunlock(&ctlr->slock);
free(p);
@@ -524,12 +525,10 @@ rtl8169ifstat(Ether* edev, void* a, long n, ulong offset)
if(n == 0){
qunlock(&ctlr->slock);
poperror();
+ free(p);
return 0;
}
- if((p = malloc(READSTR)) == nil)
- error(Enomem);
-
l = snprint(p, READSTR, "TxOk: %llud\n", dtcc->txok);
l += snprint(p+l, READSTR-l, "RxOk: %llud\n", dtcc->rxok);
l += snprint(p+l, READSTR-l, "TxEr: %llud\n", dtcc->txer);
diff --git a/sys/src/9/pc/ether82543gc.c b/sys/src/9/pc/ether82543gc.c
index 2079d8458..c764d0bcf 100644
--- a/sys/src/9/pc/ether82543gc.c
+++ b/sys/src/9/pc/ether82543gc.c
@@ -504,9 +504,10 @@ gc82543ifstat(Ether* edev, void* a, long n, ulong offset)
int i, l, r;
uvlong tuvl, ruvl;
+ p = smalloc(READSTR);
+
ctlr = edev->ctlr;
lock(&ctlr->slock);
- p = malloc(READSTR);
l = 0;
for(i = 0; i < Nstatistics; i++){
r = csr32r(ctlr, Statistics+i*4);
diff --git a/sys/src/9/pc/ether82557.c b/sys/src/9/pc/ether82557.c
index 2db2a7cdd..6fbb12a72 100644
--- a/sys/src/9/pc/ether82557.c
+++ b/sys/src/9/pc/ether82557.c
@@ -434,7 +434,7 @@ ifstat(Ether* ether, void* a, long n, ulong offset)
memmove(dump, ctlr->dump, sizeof(dump));
unlock(&ctlr->dlock);
- p = malloc(READSTR);
+ p = smalloc(READSTR);
len = snprint(p, READSTR, "transmit good frames: %lud\n", dump[0]);
len += snprint(p+len, READSTR-len, "transmit maximum collisions errors: %lud\n", dump[1]);
len += snprint(p+len, READSTR-len, "transmit late collisions errors: %lud\n", dump[2]);
diff --git a/sys/src/9/pc/ether82563.c b/sys/src/9/pc/ether82563.c
index 20fcb2a6f..34fa9809d 100644
--- a/sys/src/9/pc/ether82563.c
+++ b/sys/src/9/pc/ether82563.c
@@ -647,10 +647,11 @@ i82563ifstat(Ether *edev, void *a, long n, ulong offset)
Ctlr *ctlr;
Rbpool *b;
+ p = s = smalloc(READSTR);
+ e = p + READSTR;
+
ctlr = edev->ctlr;
qlock(&ctlr->slock);
- p = s = malloc(READSTR);
- e = p + READSTR;
for(i = 0; i < Nstatistics; i++){
r = csr32r(ctlr, Statistics + i*4);
diff --git a/sys/src/9/pc/ether82598.c b/sys/src/9/pc/ether82598.c
index 459b1fb0f..6c72474e0 100644
--- a/sys/src/9/pc/ether82598.c
+++ b/sys/src/9/pc/ether82598.c
@@ -336,10 +336,10 @@ ifstat(Ether *e, void *a, long n, ulong offset)
char *s, *p, *q;
Ctlr *c;
- c = e->ctlr;
- p = s = malloc(READSTR);
+ p = s = smalloc(READSTR);
q = p + READSTR;
+ c = e->ctlr;
readstats(c);
for(i = 0; i < nelem(stattab); i++)
if(c->stats[i] > 0)
diff --git a/sys/src/9/pc/ether83815.c b/sys/src/9/pc/ether83815.c
index 6b7bd19c8..19131b0f6 100644
--- a/sys/src/9/pc/ether83815.c
+++ b/sys/src/9/pc/ether83815.c
@@ -360,7 +360,7 @@ ifstat(Ether* ether, void* a, long n, ulong offset)
if(n == 0)
return 0;
- p = malloc(READSTR);
+ p = smalloc(READSTR);
l = snprint(p, READSTR, "Rxa: %lud\n", ctlr->rxa);
l += snprint(p+l, READSTR-l, "Rxo: %lud\n", ctlr->rxo);
l += snprint(p+l, READSTR-l, "Rlong: %lud\n", ctlr->rlong);
diff --git a/sys/src/9/pc/etherdp83820.c b/sys/src/9/pc/etherdp83820.c
index 98938e6d7..29b1bbfa9 100644
--- a/sys/src/9/pc/etherdp83820.c
+++ b/sys/src/9/pc/etherdp83820.c
@@ -920,7 +920,7 @@ dp83820ifstat(Ether* edev, void* a, long n, ulong offset)
if(n == 0)
return 0;
- p = malloc(READSTR);
+ p = smalloc(READSTR);
l = 0;
for(i = 0; i < Nmibd; i++){
r = csr32r(ctlr, Mibd+(i*sizeof(int)));
diff --git a/sys/src/9/pc/etherelnk3.c b/sys/src/9/pc/etherelnk3.c
index 9c612b136..c0a109453 100644
--- a/sys/src/9/pc/etherelnk3.c
+++ b/sys/src/9/pc/etherelnk3.c
@@ -1174,7 +1174,7 @@ ifstat(Ether* ether, void* a, long n, ulong offset)
statistics(ether);
iunlock(&ctlr->wlock);
- p = malloc(READSTR);
+ p = smalloc(READSTR);
len = snprint(p, READSTR, "interrupts: %lud\n", ctlr->interrupts);
len += snprint(p+len, READSTR-len, "bogusinterrupts: %lud\n", ctlr->bogusinterrupts);
len += snprint(p+len, READSTR-len, "timer: %lud %lud\n",
diff --git a/sys/src/9/pc/etherga620.c b/sys/src/9/pc/etherga620.c
index d7047b8a7..4c132b10c 100644
--- a/sys/src/9/pc/etherga620.c
+++ b/sys/src/9/pc/etherga620.c
@@ -343,7 +343,7 @@ ga620ifstat(Ether* edev, void* a, long n, ulong offset)
if(n == 0)
return 0;
- p = malloc(READSTR);
+ p = smalloc(READSTR);
l = 0;
for(i = 0; i < 256; i++){
if((r = ctlr->gib->statistics[i]) == 0)
@@ -1173,6 +1173,10 @@ ga620pci(void)
}
ctlr = malloc(sizeof(Ctlr));
+ if(ctlr == nil){
+ print("ga620: can't allocate memory\n");
+ continue;
+ }
ctlr->port = p->mem[0].bar & ~0x0F;
ctlr->pcidev = p;
ctlr->id = p->did<<16 | p->vid;
diff --git a/sys/src/9/pc/etherigbe.c b/sys/src/9/pc/etherigbe.c
index bf08020d5..837c93c05 100644
--- a/sys/src/9/pc/etherigbe.c
+++ b/sys/src/9/pc/etherigbe.c
@@ -599,10 +599,10 @@ igbeifstat(Ether* edev, void* a, long n, ulong offset)
int i, l, r;
uvlong tuvl, ruvl;
+ p = smalloc(READSTR);
+ l = 0;
ctlr = edev->ctlr;
qlock(&ctlr->slock);
- p = malloc(READSTR);
- l = 0;
for(i = 0; i < Nstatistics; i++){
r = csr32r(ctlr, Statistics+i*4);
if((s = statistics[i]) == nil)
@@ -1965,6 +1965,10 @@ igbepci(void)
break;
}
ctlr = malloc(sizeof(Ctlr));
+ if(ctlr == nil){
+ print("igbe: can't allocate memory\n");
+ continue;
+ }
ctlr->port = p->mem[0].bar & ~0x0F;
ctlr->pcidev = p;
ctlr->id = (p->did<<16)|p->vid;
diff --git a/sys/src/9/pc/etherm10g.c b/sys/src/9/pc/etherm10g.c
index 630376350..f759c99c0 100644
--- a/sys/src/9/pc/etherm10g.c
+++ b/sys/src/9/pc/etherm10g.c
@@ -1362,19 +1362,15 @@ lstcount(Block *b)
static long
m10gifstat(Ether *e, void *v, long n, ulong off)
{
- int l;
char *p;
Ctlr *c;
Stats s;
c = e->ctlr;
- p = malloc(READSTR+1);
- l = 0;
+ p = smalloc(READSTR);
/* no point in locking this because this is done via dma. */
memmove(&s, c->stats, sizeof s);
-
- // l +=
- snprint(p+l, READSTR,
+ snprint(p, READSTR,
"txcnt = %lud\n" "linkstat = %lud\n" "dlink = %lud\n"
"derror = %lud\n" "drunt = %lud\n" "doverrun = %lud\n"
"dnosm = %lud\n" "dnobg = %lud\n" "nrdma = %lud\n"
diff --git a/sys/src/9/pc/ethersmc.c b/sys/src/9/pc/ethersmc.c
index 65ebffcac..1c2ac8025 100644
--- a/sys/src/9/pc/ethersmc.c
+++ b/sys/src/9/pc/ethersmc.c
@@ -644,7 +644,6 @@ ifstat(Ether* ether, void* a, long n, ulong offset)
return 0;
ctlr = ether->ctlr;
- p = malloc(READSTR);
s = 0;
if (ctlr->rev > 0) {
@@ -660,6 +659,7 @@ ifstat(Ether* ether, void* a, long n, ulong offset)
}
}
+ p = smalloc(READSTR);
len = snprint(p, READSTR, "rev: 91c%s\n", (s) ? s : "???");
len += snprint(p + len, READSTR - len, "rxovrn: %uld\n", ctlr->rovrn);
len += snprint(p + len, READSTR - len, "lcar: %uld\n", ctlr->lcar);
diff --git a/sys/src/9/pc/ethervgbe.c b/sys/src/9/pc/ethervgbe.c
index 3f31800e6..e7acca81f 100644
--- a/sys/src/9/pc/ethervgbe.c
+++ b/sys/src/9/pc/ethervgbe.c
@@ -401,9 +401,8 @@ vgbeifstat(Ether* edev, void* a, long n, ulong offset)
ctlr = edev->ctlr;
- p = malloc(READSTR);
- l = 0;
- l += snprint(p+l, READSTR-l, "tx: %uld\n", ctlr->stats.tx);
+ p = smalloc(READSTR);
+ l = snprint(p+l, READSTR-l, "tx: %uld\n", ctlr->stats.tx);
l += snprint(p+l, READSTR-l, "tx [errs]: %uld\n", ctlr->stats.txe);
l += snprint(p+l, READSTR-l, "rx: %uld\n", ctlr->stats.rx);
l += snprint(p+l, READSTR-l, "intr: %uld\n", ctlr->stats.intr);
diff --git a/sys/src/9/pc/ethervt6102.c b/sys/src/9/pc/ethervt6102.c
index 575824b59..32d17afae 100644
--- a/sys/src/9/pc/ethervt6102.c
+++ b/sys/src/9/pc/ethervt6102.c
@@ -346,7 +346,7 @@ vt6102ifstat(Ether* edev, void* a, long n, ulong offset)
ctlr = edev->ctlr;
- p = malloc(READSTR);
+ p = smalloc(READSTR);
l = 0;
for(i = 0; i < Nrxstats; i++){
l += snprint(p+l, READSTR-l, "%s: %ud\n",
diff --git a/sys/src/9/pc/main.c b/sys/src/9/pc/main.c
index 7f814a3ec..52007d65a 100644
--- a/sys/src/9/pc/main.c
+++ b/sys/src/9/pc/main.c
@@ -603,7 +603,7 @@ procfork(Proc *p)
/* copy local descriptor table */
if(up->ldt != nil && up->nldt > 0){
- p->ldt = malloc(sizeof(Segdesc) * up->nldt);
+ p->ldt = smalloc(sizeof(Segdesc) * up->nldt);
memmove(p->ldt, up->ldt, sizeof(Segdesc) * up->nldt);
p->nldt = up->nldt;
}
diff --git a/sys/src/9/pc/mmu.c b/sys/src/9/pc/mmu.c
index 8e7506f7a..52b0ef563 100644
--- a/sys/src/9/pc/mmu.c
+++ b/sys/src/9/pc/mmu.c
@@ -88,6 +88,8 @@ mmuinit(void)
m->pdb[PDX(VPT)] = PADDR(m->pdb)|PTEWRITE|PTEVALID;
m->tss = malloc(sizeof(Tss));
+ if(m->tss == nil)
+ panic("mmuinit: no memory for Tss");
memset(m->tss, 0, sizeof(Tss));
m->tss->iomap = 0xDFFF<<16;
diff --git a/sys/src/9/pc/mp.c b/sys/src/9/pc/mp.c
index e8316ac74..e10e6d9d1 100644
--- a/sys/src/9/pc/mp.c
+++ b/sys/src/9/pc/mp.c
@@ -225,6 +225,8 @@ mkiointr(PCMPintr* p)
if(memcmp(mppcmp->product, "INTEL X38MLST ", 20) == 0){
if(p->busno == 1 && p->intin == 16 && p->irq == 1){
pcmpintr = malloc(sizeof(PCMPintr));
+ if(pcmpintr == nil)
+ panic("iointr: no memory for PCMPintr");
memmove(pcmpintr, p, sizeof(PCMPintr));
print("mkiointr: %20.20s bus %d intin %d irq %d\n",
(char*)mppcmp->product,
diff --git a/sys/src/9/pc/piix4smbus.c b/sys/src/9/pc/piix4smbus.c
index b05bb8f25..7ea4b8706 100644
--- a/sys/src/9/pc/piix4smbus.c
+++ b/sys/src/9/pc/piix4smbus.c
@@ -181,7 +181,9 @@ piix4smbus(void)
if(p == nil)
return nil;
- s = smalloc(sizeof(*s));
+ s = malloc(sizeof(*s));
+ if(s == nil)
+ panic("piix4smbus: no memory for SMBus");
memmove(s, &smbusproto, sizeof(*s));
s->arg = p;
diff --git a/sys/src/9/pc/sdodin.c b/sys/src/9/pc/sdodin.c
index 9b2f716bf..3f35d7f51 100644
--- a/sys/src/9/pc/sdodin.c
+++ b/sys/src/9/pc/sdodin.c
@@ -2551,7 +2551,11 @@ map(Pcidev *p, int bar)
static void
initmem(Ctlr *c)
{
- c->fis = smalloc(0x800 + 0x100*16); /* §6.1.9.3 */
+ c->fis = malloc(0x800 + 0x100*16); /* §6.1.9.3 */
+ c->cl = malloc(nelem(c->cq)*sizeof *c->cl);
+ c->cmdtab = malloc(Nctlrdrv*sizeof *c->cmdtab);
+ if(c->fis == nil || c->cl == nil || c->cmdtab == nil)
+ panic("sdodin: no memory");
c->reg[Fisbase + 0] = PCIWADDR(c->fis);
c->reg[Fisbase + 1] = Pciwaddrh(c->fis);
c->reg[Cqbase + 0] = PCIWADDR(c->cq);
@@ -2560,10 +2564,8 @@ initmem(Ctlr *c)
c->reg[Dqbase + 0] = PCIWADDR(c->dq);
c->reg[Dqbase + 1] = Pciwaddrh(c->dq);
c->reg[Dqcfg] = Dqen | nelem(c->dq);
- c->cl = smalloc(nelem(c->cq)*sizeof *c->cl);
c->reg[Clbase + 0] = PCIWADDR(c->cl);
c->reg[Clbase + 1] = Pciwaddrh(c->cl);
- c->cmdtab = smalloc(Nctlrdrv*sizeof *c->cmdtab);
}
/* §5.1.2 */
diff --git a/sys/src/9/pc/uartaxp.c b/sys/src/9/pc/uartaxp.c
index af928a1e2..53551502d 100644
--- a/sys/src/9/pc/uartaxp.c
+++ b/sys/src/9/pc/uartaxp.c
@@ -262,7 +262,7 @@ axpstatus(Uart* uart, void* buf, long n, long offset)
ccb = ((Cc*)(uart->regs))->ccb;
- p = malloc(READSTR);
+ p = smalloc(READSTR);
bs = ccb->bs;
fstat = ccb->df;
ms = ccb->ms;
diff --git a/sys/src/9/pc/uarti8250.c b/sys/src/9/pc/uarti8250.c
index f309859d9..aba0be90c 100644
--- a/sys/src/9/pc/uarti8250.c
+++ b/sys/src/9/pc/uarti8250.c
@@ -171,7 +171,7 @@ i8250status(Uart* uart, void* buf, long n, long offset)
uchar ier, lcr, mcr, msr;
ctlr = uart->regs;
- p = malloc(READSTR);
+ p = smalloc(READSTR);
mcr = ctlr->sticky[Mcr];
msr = csr8r(ctlr, Msr);
ier = ctlr->sticky[Ier];
diff --git a/sys/src/9/pc/usbehcipc.c b/sys/src/9/pc/usbehcipc.c
index 1fa9b0752..c67901bed 100644
--- a/sys/src/9/pc/usbehcipc.c
+++ b/sys/src/9/pc/usbehcipc.c
@@ -180,7 +180,11 @@ scanpci(void)
dprint("usbehci: %#x %#x: port %#lux size %#x irq %d\n",
p->vid, p->did, io, p->mem[0].size, p->intl);
- ctlr = smalloc(sizeof(Ctlr));
+ ctlr = malloc(sizeof(Ctlr));
+ if(ctlr == nil){
+ print("usbehci: no memory\n");
+ continue;
+ }
ctlr->pcidev = p;
capio = ctlr->capio = vmap(io, p->mem[0].size);
ctlr->opio = (Eopio*)((uintptr)capio + (capio->cap & 0xff));
diff --git a/sys/src/9/pc/usbohci.c b/sys/src/9/pc/usbohci.c
index fc7f9f2bd..1b9c3cf0c 100644
--- a/sys/src/9/pc/usbohci.c
+++ b/sys/src/9/pc/usbohci.c
@@ -2383,15 +2383,19 @@ scanpci(void)
dprint("ohci: %x/%x port 0x%lux size 0x%x irq %d\n",
p->vid, p->did, mem, p->mem[0].size, p->intl);
if(mem == 0){
- print("ohci: failed to map registers\n");
+ print("usbohci: failed to map registers\n");
continue;
}
if(p->intl == 0xFF || p->intl == 0) {
- print("ohci: no irq assigned for port %#lux\n", mem);
+ print("usbohci: no irq assigned for port %#lux\n", mem);
continue;
}
- ctlr = smalloc(sizeof(Ctlr));
+ ctlr = malloc(sizeof(Ctlr));
+ if(ctlr == nil){
+ print("usbohci: no memory\n");
+ continue;
+ }
ctlr->pcidev = p;
ctlr->ohci = vmap(mem, p->mem[0].size);
dprint("scanpci: ctlr %#p, ohci %#p\n", ctlr, ctlr->ohci);
@@ -2403,7 +2407,7 @@ scanpci(void)
break;
}
if(i == Nhcis)
- print("ohci: bug: no more controllers\n");
+ print("usbohci: bug: no more controllers\n");
}
}
diff --git a/sys/src/9/pc/usbuhci.c b/sys/src/9/pc/usbuhci.c
index 3b3af719f..a063fcd9a 100644
--- a/sys/src/9/pc/usbuhci.c
+++ b/sys/src/9/pc/usbuhci.c
@@ -2139,7 +2139,12 @@ scanpci(void)
dprint("uhci: %#x %#x: port %#ux size %#x irq %d\n",
p->vid, p->did, io, p->mem[4].size, p->intl);
- ctlr = smalloc(sizeof(Ctlr));
+ ctlr = malloc(sizeof(Ctlr));
+ if(ctlr == nil){
+ iofree(io);
+ print("usbuhci: no memory\n");
+ continue;
+ }
ctlr->pcidev = p;
ctlr->port = io;
for(i = 0; i < Nhcis; i++)
@@ -2148,7 +2153,7 @@ scanpci(void)
break;
}
if(i == Nhcis)
- print("uhci: bug: no more controllers\n");
+ print("usbuhci: bug: no more controllers\n");
}
}
diff --git a/sys/src/9/pc/wavelan.c b/sys/src/9/pc/wavelan.c
index bf42c3c52..969c5f985 100644
--- a/sys/src/9/pc/wavelan.c
+++ b/sys/src/9/pc/wavelan.c
@@ -169,7 +169,7 @@ w_seek(Ctlr* ctlr, ushort id, ushort offset, int chan)
static ushort off[] = { WR_Off0, WR_Off1 };
if(chan != 0 && chan != 1)
- panic("wavelan: bad chan\n");
+ panic("wavelan: bad chan");
csr_outs(ctlr, sel[chan], id);
csr_outs(ctlr, off[chan], offset);
for (i=0; i<WTmOut; i++){
@@ -846,7 +846,7 @@ w_ifstat(Ether* ether, void* a, long n, ulong offset)
if(n == 0 || offset != 0)
return 0;
- p = malloc(READSTR);
+ p = smalloc(READSTR);
l = 0;
PRINTSTAT("Signal: %d\n", ctlr->signal-149);
diff --git a/sys/src/9/port/devuart.c b/sys/src/9/port/devuart.c
index fbf9a80d3..df5d515a4 100644
--- a/sys/src/9/port/devuart.c
+++ b/sys/src/9/port/devuart.c
@@ -509,7 +509,7 @@ uartwrite(Chan *c, void *buf, long n, vlong)
poperror();
break;
case Nctlqid:
- cmd = malloc(n+1);
+ cmd = smalloc(n+1);
memmove(cmd, buf, n);
cmd[n] = 0;
qlock(p);
diff --git a/sys/src/9/port/portclock.c b/sys/src/9/port/portclock.c
index 624283d3c..3f7d4be7c 100644
--- a/sys/src/9/port/portclock.c
+++ b/sys/src/9/port/portclock.c
@@ -214,6 +214,8 @@ timersinit(void)
*/
todinit();
t = malloc(sizeof(*t));
+ if(t == nil)
+ panic("timersinit: no memory for Timer");
t->tmode = Tperiodic;
t->tt = nil;
t->tns = 1000000000/HZ;
@@ -229,6 +231,8 @@ addclock0link(void (*f)(void), int ms)
/* Synchronize to hztimer if ms is 0 */
nt = malloc(sizeof(Timer));
+ if(nt == nil)
+ panic("addclock0link: no memory for Timer");
if(ms == 0)
ms = 1000/HZ;
nt->tns = (vlong)ms*1000000LL;