Parcourir la source

Plan 9 from Bell Labs 2011-06-22

David du Colombier il y a 13 ans
Parent
commit
834ca8049f
51 fichiers modifiés avec 318 ajouts et 38 suppressions
  1. 2 0
      sys/src/9/ip/netlog.c
  2. 2 0
      sys/src/9/pc/devarch.c
  3. 2 0
      sys/src/9/pc/devether.c
  4. 2 0
      sys/src/9/pc/devi82365.c
  5. 2 0
      sys/src/9/pc/devpccard.c
  6. 2 0
      sys/src/9/pc/devvga.c
  7. 4 0
      sys/src/9/pc/ether2000.c
  8. 6 0
      sys/src/9/pc/ether2114x.c
  9. 4 0
      sys/src/9/pc/ether79c970.c
  10. 2 0
      sys/src/9/pc/ether8003.c
  11. 8 0
      sys/src/9/pc/ether8139.c
  12. 12 3
      sys/src/9/pc/ether8169.c
  13. 6 0
      sys/src/9/pc/ether82543gc.c
  14. 10 0
      sys/src/9/pc/ether82557.c
  15. 8 0
      sys/src/9/pc/ether82563.c
  16. 7 0
      sys/src/9/pc/ether82598.c
  17. 4 0
      sys/src/9/pc/ether83815.c
  18. 9 0
      sys/src/9/pc/etherdp83820.c
  19. 4 0
      sys/src/9/pc/etherec2t.c
  20. 10 0
      sys/src/9/pc/etherelnk3.c
  21. 37 0
      sys/src/9/pc/etherga620.c
  22. 29 19
      sys/src/9/pc/etherigbe.c
  23. 2 0
      sys/src/9/pc/etherm10g.c
  24. 3 3
      sys/src/9/pc/ethersmc.c
  25. 2 0
      sys/src/9/pc/ethervgbe.c
  26. 6 0
      sys/src/9/pc/ethervt6102.c
  27. 6 0
      sys/src/9/pc/ethervt6105m.c
  28. 2 0
      sys/src/9/pc/etherwavelan.c
  29. 2 0
      sys/src/9/pc/mmu.c
  30. 3 1
      sys/src/9/pc/mp.c
  31. 4 0
      sys/src/9/pc/pci.c
  32. 2 0
      sys/src/9/pc/sdata.c
  33. 5 2
      sys/src/9/pc/uartaxp.c
  34. 3 1
      sys/src/9/pc/uarti8250.c
  35. 2 1
      sys/src/9/pc/uartisa.c
  36. 2 0
      sys/src/9/pc/uartpci.c
  37. 2 0
      sys/src/9/pc/wavelan.c
  38. 14 0
      sys/src/9/port/devaoe.c
  39. 2 0
      sys/src/9/port/devbridge.c
  40. 4 0
      sys/src/9/port/devflash.c
  41. 36 4
      sys/src/9/port/devpipe.c
  42. 5 0
      sys/src/9/port/devpnp.c
  43. 2 0
      sys/src/9/port/devproc.c
  44. 7 2
      sys/src/9/port/devsd.c
  45. 6 0
      sys/src/9/port/devssl.c
  46. 2 0
      sys/src/9/port/devuart.c
  47. 2 0
      sys/src/9/port/devwd.c
  48. 2 0
      sys/src/9/port/log.c
  49. 9 2
      sys/src/9/port/master
  50. 4 0
      sys/src/9/port/netif.c
  51. 5 0
      sys/src/9/port/portclock.c

+ 2 - 0
sys/src/9/ip/netlog.c

@@ -85,6 +85,8 @@ netlogopen(Fs *f)
 	if(f->alog->opens == 0){
 		if(f->alog->buf == nil)
 			f->alog->buf = malloc(Nlog);
+		if(f->alog->buf == nil)
+			error(Enomem);
 		f->alog->rptr = f->alog->buf;
 		f->alog->end = f->alog->buf + Nlog;
 	}

+ 2 - 0
sys/src/9/pc/devarch.c

@@ -851,6 +851,8 @@ archctlread(Chan*, void *a, long nn, vlong offset)
 	char *buf, *p, *ep;
 
 	p = buf = malloc(READSTR);
+	if(p == nil)
+		error(Enomem);
 	ep = p + READSTR;
 	p = seprint(p, ep, "cpu %s %lud%s\n",
 		cputype->name, (ulong)(m->cpuhz+999999)/1000000,

+ 2 - 0
sys/src/9/pc/devether.c

@@ -378,6 +378,8 @@ etherprobe(int cardno, int ctlrno)
 	char buf[128], name[32];
 
 	ether = malloc(sizeof(Ether));
+	if(ether == nil)
+		error(Enomem);
 	memset(ether, 0, sizeof(Ether));
 	ether->ctlrno = ctlrno;
 	ether->tbdf = BUSUNKNOWN;

+ 2 - 0
sys/src/9/pc/devi82365.c

@@ -766,6 +766,8 @@ i82365read(Chan *c, void *a, long n, vlong off)
 		return pcmread(SLOTNO(c), TYPE(c) == Qattr, a, n, off);
 	case Qctl:
 		buf = p = malloc(READSTR);
+		if(p == nil)
+			error(Enomem);
 		e = p + READSTR;
 		pp = slot + SLOTNO(c);
 

+ 2 - 0
sys/src/9/pc/devpccard.c

@@ -1293,6 +1293,8 @@ pccardread(Chan *c, void *a, long n, vlong offset)
 
 	case Qctl:
 		buf = p = malloc(READSTR);
+		if(p == nil)
+			error(Enomem);
 		buf[0] = 0;
 		e = p + READSTR;
 

+ 2 - 0
sys/src/9/pc/devvga.c

@@ -170,6 +170,8 @@ vgaread(Chan* c, void* a, long n, vlong off)
 		scr = &vgascreen[0];
 
 		p = malloc(READSTR);
+		if(p == nil)
+			error(Enomem);
 		if(waserror()){
 			free(p);
 			nexterror();

+ 4 - 0
sys/src/9/pc/ether2000.c

@@ -98,6 +98,8 @@ ne2000pnp(Ether* edev)
 			if(p->ccrb != 0x02 || p->ccru != 0)
 				continue;
 			ctlr = malloc(sizeof(Ctlr));
+			if(ctlr == nil)
+				error(Enomem);
 			ctlr->pcidev = p;
 
 			if(ctlrhead != nil)
@@ -162,6 +164,8 @@ ne2000reset(Ether* edev)
 
 	edev->ctlr = malloc(sizeof(Dp8390));
 	dp8390 = edev->ctlr;
+	if(dp8390 == nil)
+		error(Enomem);
 	dp8390->width = 2;
 	dp8390->ram = 0;
 

+ 6 - 0
sys/src/9/pc/ether2114x.c

@@ -323,6 +323,8 @@ ifstat(Ether* ether, void* a, long n, ulong offset)
 		return 0;
 
 	p = malloc(READSTR);
+	if(p == nil)
+		error(Enomem);
 	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);
@@ -1465,6 +1467,8 @@ srom(Ctlr* ctlr)
 	sromr(ctlr, 0);
 	if(ctlr->srom == nil)
 		ctlr->srom = malloc((1<<ctlr->sromsz)*sizeof(ushort));
+	if(ctlr->srom == nil)
+		error(Enomem);
 	for(i = 0; i < (1<<ctlr->sromsz); i++){
 		x = sromr(ctlr, i);
 		ctlr->srom[2*i] = x;
@@ -1665,6 +1669,8 @@ dec2114xpci(void)
 		 * bar[1] is the memory-mapped register address.
 		 */
 		ctlr = malloc(sizeof(Ctlr));
+		if(ctlr == nil)
+			error(Enomem);
 		ctlr->port = p->mem[0].bar & ~0x01;
 		ctlr->pcidev = p;
 		ctlr->id = (p->did<<16)|p->vid;

+ 4 - 0
sys/src/9/pc/ether79c970.c

@@ -205,6 +205,8 @@ ifstat(Ether* ether, void* a, long n, ulong offset)
 		return 0;
 
 	p = malloc(READSTR);
+	if(p == nil)
+		error(Enomem);
 	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);
@@ -482,6 +484,8 @@ amd79c970pci(void)
 			continue;
 		}
 		ctlr = malloc(sizeof(Ctlr));
+		if(ctlr == nil)
+			error(Enomem);
 		ctlr->port = p->mem[0].bar & ~0x01;
 		ctlr->pcidev = p;
 

+ 2 - 0
sys/src/9/pc/ether8003.c

@@ -230,6 +230,8 @@ reset(Ether* ether)
 
 	ether->ctlr = malloc(sizeof(Dp8390));
 	ctlr = ether->ctlr;
+	if(ctlr == nil)
+		error(Enomem);
 	ctlr->ram = 1;
 
 	if((id & 0xFE) == 0x2A)

+ 8 - 0
sys/src/9/pc/ether8139.c

@@ -311,6 +311,8 @@ rtl8139ifstat(Ether* edev, void* a, long n, ulong offset)
 
 	ctlr = edev->ctlr;
 	p = malloc(READSTR);
+	if(p == nil)
+		error(Enomem);
 	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);
@@ -466,6 +468,10 @@ rtl8139attach(Ether* edev)
 	if(ctlr->alloc == nil){
 		ctlr->rblen = 1<<((Rblen>>RblenSHIFT)+13);
 		ctlr->alloc = mallocz(ctlr->rblen+16 + Ntd*Tdbsz + 32, 0);
+		if(ctlr->alloc == nil) {
+			qunlock(&ctlr->alock);
+			error(Enomem);
+		}
 		rtl8139init(edev);
 	}
 	qunlock(&ctlr->alock);
@@ -764,6 +770,8 @@ rtl8139pnp(Ether* edev)
 			if(p->ccrb != 0x02 || p->ccru != 0)
 				continue;
 			ctlr = malloc(sizeof(Ctlr));
+			if(ctlr == nil)
+				error(Enomem);
 			ctlr->pcidev = p;
 			ctlr->id = (p->did<<16)|p->vid;
 

+ 12 - 3
sys/src/9/pc/ether8169.c

@@ -833,9 +833,6 @@ rtl8169attach(Ether* edev)
 	ctlr = edev->ctlr;
 	qlock(&ctlr->alock);
 	if(ctlr->init == 0){
-		/*
-		 * Handle allocation/init errors here.
-		 */
 		ctlr->td = mallocalign(sizeof(D)*Ntd, 256, 0, 0);
 		ctlr->tb = malloc(Ntd*sizeof(Block*));
 		ctlr->ntd = Ntd;
@@ -843,6 +840,16 @@ rtl8169attach(Ether* edev)
 		ctlr->rb = malloc(Nrd*sizeof(Block*));
 		ctlr->nrd = Nrd;
 		ctlr->dtcc = mallocalign(sizeof(Dtcc), 64, 0, 0);
+		if(ctlr->td == nil || ctlr->tb == nil || ctlr->rd == nil ||
+		   ctlr->rb == nil || ctlr->dtcc == nil) {
+			free(ctlr->td);
+			free(ctlr->tb);
+			free(ctlr->rd);
+			free(ctlr->rb);
+			free(ctlr->dtcc);
+			qunlock(&ctlr->alock);
+			error(Enomem);
+		}
 		rtl8169init(edev);
 		ctlr->init = 1;
 	}
@@ -1131,6 +1138,8 @@ rtl8169pci(void)
 			continue;
 		}
 		ctlr = malloc(sizeof(Ctlr));
+		if(ctlr == nil)
+			error(Enomem);
 		ctlr->port = port;
 		ctlr->pcidev = p;
 		ctlr->pciv = i;

+ 6 - 0
sys/src/9/pc/ether82543gc.c

@@ -507,6 +507,10 @@ gc82543ifstat(Ether* edev, void* a, long n, ulong offset)
 	ctlr = edev->ctlr;
 	lock(&ctlr->slock);
 	p = malloc(READSTR);
+	if(p == nil) {
+		unlock(&ctlr->slock);
+		error(Enomem);
+	}
 	l = 0;
 	for(i = 0; i < Nstatistics; i++){
 		r = csr32r(ctlr, Statistics+i*4);
@@ -1282,6 +1286,8 @@ gc82543pci(void)
 					cls*4);
 		}
 		ctlr = malloc(sizeof(Ctlr));
+		if(ctlr == nil)
+			error(Enomem);
 		ctlr->port = p->mem[0].bar & ~0x0F;
 		ctlr->pcidev = p;
 		ctlr->id = (p->did<<16)|p->vid;

+ 10 - 0
sys/src/9/pc/ether82557.c

@@ -435,6 +435,8 @@ ifstat(Ether* ether, void* a, long n, ulong offset)
 	unlock(&ctlr->dlock);
 
 	p = malloc(READSTR);
+	if(p == nil)
+		error(Enomem);
 	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]);
@@ -795,6 +797,10 @@ ctlrinit(Ctlr* ctlr)
 	 */
 	ilock(&ctlr->cblock);
 	ctlr->cbr = malloc(ctlr->ncb*sizeof(Cb));
+	if(ctlr->cbr == nil) {
+		iunlock(&ctlr->cblock);
+		error(Enomem);
+	}
 	for(i = 0; i < ctlr->ncb; i++){
 		ctlr->cbr[i].status = CbC|CbOK;
 		ctlr->cbr[i].command = CbS|CbNOP;
@@ -911,6 +917,8 @@ reread:
 	if(ctlr->eepromsz == 0){
 		ctlr->eepromsz = 8-size;
 		ctlr->eeprom = malloc((1<<ctlr->eepromsz)*sizeof(ushort));
+		if(ctlr->eeprom == nil)
+			error(Enomem);
 		goto reread;
 	}
 
@@ -971,6 +979,8 @@ i82557pci(void)
 		}
 
 		ctlr = malloc(sizeof(Ctlr));
+		if(ctlr == nil)
+			error(Enomem);
 		ctlr->port = port;
 		ctlr->pcidev = p;
 		ctlr->nop = nop;

+ 8 - 0
sys/src/9/pc/ether82563.c

@@ -617,6 +617,10 @@ i82563ifstat(Ether* edev, void* a, long n, ulong offset)
 	ctlr = edev->ctlr;
 	qlock(&ctlr->slock);
 	p = s = malloc(READSTR);
+	if(p == nil) {
+		qunlock(&ctlr->slock);
+		error(Enomem);
+	}
 	e = p + READSTR;
 
 	for(i = 0; i < Nstatistics; i++){
@@ -1653,6 +1657,10 @@ i82563pci(void)
 			continue;
 		}
 		ctlr = malloc(sizeof(Ctlr));
+		if(ctlr == nil) {
+			vunmap(mem, p->mem[0].size);
+			error(Enomem);
+		}
 		ctlr->port = io;
 		ctlr->pcidev = p;
 		ctlr->type = type;

+ 7 - 0
sys/src/9/pc/ether82598.c

@@ -338,6 +338,8 @@ ifstat(Ether *e, void *a, long n, ulong offset)
 
 	c = e->ctlr;
 	p = s = malloc(READSTR);
+	if(p == nil)
+		error(Enomem);
 	q = p + READSTR;
 
 	readstats(c);
@@ -923,6 +925,11 @@ scan(void)
 			continue;
 		}
 		c = malloc(sizeof *c);
+		if(c == nil) {
+			vunmap(mem, p->mem[0].size);
+			vunmap(mem3, p->mem[3].size);
+			error(Enomem);
+		}
 		c->p = p;
 		c->reg = (u32int*)mem;
 		c->reg3 = (u32int*)mem3;

+ 4 - 0
sys/src/9/pc/ether83815.c

@@ -361,6 +361,8 @@ ifstat(Ether* ether, void* a, long n, ulong offset)
 		return 0;
 
 	p = malloc(READSTR);
+	if(p == nil)
+		error(Enomem);
 	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);
@@ -1068,6 +1070,8 @@ scanpci83815(void)
 		 * bar[1] is the memory-mapped register address.
 		 */
 		ctlr = malloc(sizeof(Ctlr));
+		if(ctlr == nil)
+			error(Enomem);
 		ctlr->port = p->mem[0].bar & ~0x01;
 		ctlr->pcidev = p;
 		ctlr->id = id;

+ 9 - 0
sys/src/9/pc/etherdp83820.c

@@ -921,6 +921,8 @@ dp83820ifstat(Ether* edev, void* a, long n, ulong offset)
 		return 0;
 
 	p = malloc(READSTR);
+	if(p == nil)
+		error(Enomem);
 	l = 0;
 	for(i = 0; i < Nmibd; i++){
 		r = csr32r(ctlr, Mibd+(i*sizeof(int)));
@@ -1059,6 +1061,8 @@ reread:
 	if(ctlr->eepromsz == 0){
 		ctlr->eepromsz = 8-size;
 		ctlr->eeprom = malloc((1<<ctlr->eepromsz)*sizeof(ushort));
+		if(ctlr->eeprom == nil)
+			error(Enomem);
 		goto reread;
 	}
 
@@ -1165,6 +1169,10 @@ dp83820pci(void)
 		}
 
 		ctlr = malloc(sizeof(Ctlr));
+		if(ctlr == nil) {
+			vunmap(mem, p->mem[1].size);
+			error(Enomem);
+		}
 		ctlr->port = p->mem[1].bar & ~0x0F;
 		ctlr->pcidev = p;
 		ctlr->id = (p->did<<16)|p->vid;
@@ -1172,6 +1180,7 @@ dp83820pci(void)
 		ctlr->nic = mem;
 		if(dp83820reset(ctlr)){
 			free(ctlr);
+			vunmap(mem, p->mem[1].size);
 			continue;
 		}
 		pcisetbme(p);

+ 4 - 0
sys/src/9/pc/etherec2t.c

@@ -91,6 +91,10 @@ reset(Ether* ether)
 
 	ether->ctlr = malloc(sizeof(Dp8390));
 	ctlr = ether->ctlr;
+	if(ctlr == nil) {
+		iofree(port);
+		error(Enomem);
+	}
 	ctlr->width = 2;
 	ctlr->ram = 0;
 

+ 10 - 0
sys/src/9/pc/etherelnk3.c

@@ -446,6 +446,8 @@ init905(Ctlr* ctlr)
 	 *	make sure each entry is 8-byte aligned.
 	 */
 	ctlr->upbase = malloc((ctlr->nup+1)*sizeof(Pd));
+	if(ctlr->upbase == nil)
+		error(Enomem);
 	ctlr->upr = (Pd*)ROUNDUP((ulong)ctlr->upbase, 8);
 
 	prev = ctlr->upr;
@@ -465,6 +467,10 @@ init905(Ctlr* ctlr)
 	ctlr->uphead = ctlr->upr;
 
 	ctlr->dnbase = malloc((ctlr->ndn+1)*sizeof(Pd));
+	if(ctlr->dnbase == nil) {
+		free(ctlr->upbase);
+		error(Enomem);
+	}
 	ctlr->dnr = (Pd*)ROUNDUP((ulong)ctlr->dnbase, 8);
 
 	prev = ctlr->dnr;
@@ -1175,6 +1181,8 @@ ifstat(Ether* ether, void* a, long n, ulong offset)
 	iunlock(&ctlr->wlock);
 
 	p = malloc(READSTR);
+	if(p == nil)
+		error(Enomem);
 	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",
@@ -1243,6 +1251,8 @@ tcmadapter(int port, int irq, Pcidev* pcidev)
 	Ctlr *ctlr;
 
 	ctlr = malloc(sizeof(Ctlr));
+	if(ctlr == nil)
+		error(Enomem);
 	ctlr->port = port;
 	ctlr->irq = irq;
 	ctlr->pcidev = pcidev;

+ 37 - 0
sys/src/9/pc/etherga620.c

@@ -344,6 +344,8 @@ ga620ifstat(Ether* edev, void* a, long n, ulong offset)
 	if(n == 0)
 		return 0;
 	p = malloc(READSTR);
+	if(p == nil)
+		error(Enomem);
 	l = 0;
 	for(i = 0; i < 256; i++){
 		if((r = ctlr->gib->statistics[i]) == 0)
@@ -749,10 +751,30 @@ ga620init(Ether* edev)
 	ea = edev->ea[2]<<24 | edev->ea[3]<<16 | edev->ea[4]<<8 | edev->ea[5];
 	csr32w(ctlr, Mac+4, ea);
 
+	ctlr->gib = nil;
+	ctlr->er = nil;
+	ctlr->srb = nil;
+	ctlr->sr = nil;
+	ctlr->rsr = nil;
+	if(waserror()) {
+		free(ctlr->gib);
+		free(ctlr->er);
+		free(ctlr->srb);
+		free(ctlr->sr);
+		free(ctlr->rsr);
+		ctlr->gib = nil;
+		ctlr->er = nil;
+		ctlr->srb = nil;
+		ctlr->sr = nil;
+		ctlr->rsr = nil;
+		nexterror();
+	}
 	/*
 	 * General Information Block.
 	 */
 	ctlr->gib = malloc(sizeof(Gib));
+	if(ctlr->gib == nil)
+		error(Enomem);
 	sethost64(&host64, ctlr->gib);
 	csr32w(ctlr, Gip, host64.hi);
 	csr32w(ctlr, Gip+4, host64.lo);
@@ -763,6 +785,8 @@ ga620init(Ether* edev)
 	 * tell the NIC where it is and initialise the indices.
 	 */
 	ctlr->er = malign(sizeof(Ere)*Ner);
+	if(ctlr->er == nil)
+		error(Enomem);
 	sethost64(&ctlr->gib->ercb.addr, ctlr->er);
 	sethost64(&ctlr->gib->epp, ctlr->epi);
 	csr32w(ctlr, Eci, 0);
@@ -795,6 +819,8 @@ ga620init(Ether* edev)
 	 * with this entry so an external array must be kept.
 	 */
 	ctlr->sr = malign(sizeof(Sbd)*Nsr);
+	if(ctlr->sr == nil)
+		error(Enomem);
 	sethost64(&ctlr->gib->srcb.addr, ctlr->sr);
 	if(ctlr->hardwarecksum)
 		flags = TcpUdpCksum|NoPseudoHdrCksum|HostRing;
@@ -806,11 +832,15 @@ ga620init(Ether* edev)
 	sethost64(&ctlr->gib->scp, ctlr->sci);
 	csr32w(ctlr, Spi, 0);
 	ctlr->srb = malloc(sizeof(Block*)*Nsr);
+	if(ctlr->srb == nil)
+		error(Enomem);
 
 	/*
 	 * Receive Standard Ring.
 	 */
 	ctlr->rsr = malign(sizeof(Rbd)*Nrsr);
+	if(ctlr->rsr == nil)
+		error(Enomem);
 	sethost64(&ctlr->gib->rsrcb.addr, ctlr->rsr);
 	if(ctlr->hardwarecksum)
 		flags = TcpUdpCksum|NoPseudoHdrCksum;
@@ -831,6 +861,9 @@ ga620init(Ether* edev)
 	 * tell the NIC where it is and initialise the indices.
 	 */
 	ctlr->rrr = malign(sizeof(Rbd)*Nrrr);
+	if(ctlr->rrr == nil)
+		error(Enomem);
+	poperror();
 	sethost64(&ctlr->gib->rrrcb.addr, ctlr->rrr);
 	ctlr->gib->rrrcb.control = Nrrr<<16 | 0;
 	sethost64(&ctlr->gib->rrrpp, ctlr->rrrpi);
@@ -1173,6 +1206,10 @@ ga620pci(void)
 		}
 
 		ctlr = malloc(sizeof(Ctlr));
+		if(ctlr == nil) {
+			vunmap(mem, p->mem[0].size);
+			error(Enomem);
+		}
 		ctlr->port = p->mem[0].bar & ~0x0F;
 		ctlr->pcidev = p;
 		ctlr->id = p->did<<16 | p->vid;

+ 29 - 19
sys/src/9/pc/etherigbe.c

@@ -602,6 +602,10 @@ igbeifstat(Ether* edev, void* a, long n, ulong offset)
 	ctlr = edev->ctlr;
 	qlock(&ctlr->slock);
 	p = malloc(READSTR);
+	if(p == nil) {
+		qunlock(&ctlr->slock);
+		error(Enomem);
+	}
 	l = 0;
 	for(i = 0; i < Nstatistics; i++){
 		r = csr32r(ctlr, Statistics+i*4);
@@ -1207,25 +1211,10 @@ igbeattach(Ether* edev)
 		return;
 	}
 
-	ctlr->nrd = ROUND(Nrd, 8);
-	ctlr->ntd = ROUND(Ntd, 8);
-	ctlr->alloc = malloc(ctlr->nrd*sizeof(Rd)+ctlr->ntd*sizeof(Td) + 127);
-	if(ctlr->alloc == nil){
-		print("igbe: can't allocate ctlr->alloc\n");
-		qunlock(&ctlr->alock);
-		return;
-	}
-	ctlr->rdba = (Rd*)ROUNDUP((uintptr)ctlr->alloc, 128);
-	ctlr->tdba = (Td*)(ctlr->rdba+ctlr->nrd);
-
-	ctlr->rb = malloc(ctlr->nrd*sizeof(Block*));
-	ctlr->tb = malloc(ctlr->ntd*sizeof(Block*));
-	if (ctlr->rb == nil || ctlr->tb == nil) {
-		print("igbe: can't allocate ctlr->rb or ctlr->tb\n");
-		qunlock(&ctlr->alock);
-		return;
-	}
-
+	ctlr->tb = nil;
+	ctlr->rb = nil;
+	ctlr->alloc = nil;
+	ctlr->nrb = 0;
 	if(waserror()){
 		while(ctlr->nrb > 0){
 			bp = igberballoc();
@@ -1243,6 +1232,23 @@ igbeattach(Ether* edev)
 		nexterror();
 	}
 
+	ctlr->nrd = ROUND(Nrd, 8);
+	ctlr->ntd = ROUND(Ntd, 8);
+	ctlr->alloc = malloc(ctlr->nrd*sizeof(Rd)+ctlr->ntd*sizeof(Td) + 127);
+	if(ctlr->alloc == nil) {
+		print("igbe: can't allocate ctlr->alloc\n");
+		error(Enomem);
+	}
+	ctlr->rdba = (Rd*)ROUNDUP((uintptr)ctlr->alloc, 128);
+	ctlr->tdba = (Td*)(ctlr->rdba+ctlr->nrd);
+
+	ctlr->rb = malloc(ctlr->nrd*sizeof(Block*));
+	ctlr->tb = malloc(ctlr->ntd*sizeof(Block*));
+	if (ctlr->rb == nil || ctlr->tb == nil) {
+		print("igbe: can't allocate ctlr->rb or ctlr->tb\n");
+		error(Enomem);
+	}
+
 	for(ctlr->nrb = 0; ctlr->nrb < Nrb; ctlr->nrb++){
 		if((bp = allocb(Rbsz)) == nil)
 			break;
@@ -1965,6 +1971,10 @@ igbepci(void)
 				break;
 		}
 		ctlr = malloc(sizeof(Ctlr));
+		if(ctlr == nil) {
+			vunmap(mem, p->mem[0].size);
+			error(Enomem);
+		}
 		ctlr->port = p->mem[0].bar & ~0x0F;
 		ctlr->pcidev = p;
 		ctlr->id = (p->did<<16)|p->vid;

+ 2 - 0
sys/src/9/pc/etherm10g.c

@@ -1369,6 +1369,8 @@ m10gifstat(Ether *e, void *v, long n, ulong off)
 
 	c = e->ctlr;
 	p = malloc(READSTR+1);
+	if(p == nil)
+		error(Enomem);
 	l = 0;
 	/* no point in locking this because this is done via dma. */
 	memmove(&s, c->stats, sizeof s);

+ 3 - 3
sys/src/9/pc/ethersmc.c

@@ -634,17 +634,17 @@ ifstat(Ether* ether, void* a, long n, ulong offset)
 		[8]	"100-FD",
 		[9]	"110",
 	};
-
 	Smc91xx* ctlr;
-	char* p;
+	char *p, *s;
 	int r, len;
-	char* s;
 	
 	if (n == 0)
 		return 0;
 
 	ctlr = ether->ctlr;
 	p = malloc(READSTR);
+	if(p == nil)
+		error(Enomem);
 
 	s = 0;
 	if (ctlr->rev > 0) {

+ 2 - 0
sys/src/9/pc/ethervgbe.c

@@ -402,6 +402,8 @@ vgbeifstat(Ether* edev, void* a, long n, ulong offset)
 	ctlr = edev->ctlr;
 
 	p = malloc(READSTR);
+	if(p == nil)
+		error(Enomem);
 	l = 0;
 	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);

+ 6 - 0
sys/src/9/pc/ethervt6102.c

@@ -347,6 +347,8 @@ vt6102ifstat(Ether* edev, void* a, long n, ulong offset)
 	ctlr = edev->ctlr;
 
 	p = malloc(READSTR);
+	if(p == nil)
+		error(Enomem);
 	l = 0;
 	for(i = 0; i < Nrxstats; i++){
 		l += snprint(p+l, READSTR-l, "%s: %ud\n",
@@ -967,6 +969,10 @@ vt6102pci(void)
 			continue;
 		}
 		ctlr = malloc(sizeof(Ctlr));
+		if(ctlr == nil) {
+			iofree(port);
+			error(Enomem);
+		}
 		ctlr->port = port;
 		ctlr->pcidev = p;
 		ctlr->id = (p->did<<16)|p->vid;

+ 6 - 0
sys/src/9/pc/ethervt6105m.c

@@ -442,6 +442,8 @@ vt6105Mifstat(Ether* edev, void* a, long n, ulong offset)
 
 	alloc = malloc(READSTR);
 	p = alloc;
+	if(p == nil)
+		error(Enomem);
 	e = p + READSTR;
 	for(i = 0; i < Nrxstats; i++){
 		p = seprint(p, e, "%s: %ud\n", rxstats[i], ctlr->rxstats[i]);
@@ -1132,6 +1134,10 @@ vt6105Mpci(void)
 			continue;
 		}
 		ctlr = malloc(sizeof(Ctlr));
+		if(ctlr == nil) {
+			iofree(port);
+			error(Enomem);
+		}
 		ctlr->port = port;
 		ctlr->pcidev = p;
 		ctlr->id = (p->did<<16)|p->vid;

+ 2 - 0
sys/src/9/pc/etherwavelan.c

@@ -117,6 +117,8 @@ wavelanpciscan(void)
 		}
 
 		ctlr = malloc(sizeof(Ctlr));
+		if(ctlr == nil)
+			error(Enomem);
 		ctlr->pcidev = p;
 		mem = vmap(p->mem[0].bar&~0xF, p->mem[0].size);
 		if(mem == nil){

+ 2 - 0
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");
 	memset(m->tss, 0, sizeof(Tss));
 	m->tss->iomap = 0xDFFF<<16;
 

+ 3 - 1
sys/src/9/pc/mp.c

@@ -185,7 +185,7 @@ mkiointr(PCMPintr* p)
 	aintr->intr = p;
 
 	if(0)
-		print("iointr: type %d intr type %d flags %#o "
+		print("mkiointr: type %d intr type %d flags %#o "
 			"bus %d irq %d apicno %d intin %d\n",
 			p->type, p->intr, p->flags,
 			p->busno, p->irq, p->apicno, p->intin);
@@ -196,6 +196,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("mkiointr: no memory");
 			memmove(pcmpintr, p, sizeof(PCMPintr));
 			print("mkiointr: %20.20s bus %d intin %d irq %d\n",
 				(char*)mppcmp->product,

+ 4 - 0
sys/src/9/pc/pci.c

@@ -200,6 +200,8 @@ pcibusmap(Pcidev *root, ulong *pmema, ulong *pioa, int wrreg)
 
 	ntb *= (PciCIS-PciBAR0)/4;
 	table = malloc(2*ntb*sizeof(Pcisiz));
+	if(table == nil)
+		error(Enomem);
 	itb = table;
 	mtb = table+ntb;
 
@@ -389,6 +391,8 @@ pcilscan(int bno, Pcidev** list)
 			if(l == 0xFFFFFFFF || l == 0)
 				continue;
 			p = malloc(sizeof(*p));
+			if(p == nil)
+				error(Enomem);
 			p->tbdf = tbdf;
 			p->vid = l;
 			p->did = l>>16;

+ 2 - 0
sys/src/9/pc/sdata.c

@@ -2141,6 +2141,8 @@ ataenable(SDev* sdev)
 		if(ctlr->pcidev != nil)
 			pcisetbme(ctlr->pcidev);
 		ctlr->prdt = mallocalign(Nprd*sizeof(Prd), 4, 0, 4*1024);
+		if(ctlr->prdt == nil)
+			error(Enomem);
 	}
 	snprint(name, sizeof(name), "%s (%s)", sdev->name, sdev->ifc->name);
 	intrenable(ctlr->irq, atainterrupt, ctlr, ctlr->tbdf, name);

+ 5 - 2
sys/src/9/pc/uartaxp.c

@@ -260,9 +260,10 @@ axpstatus(Uart* uart, void* buf, long n, long offset)
 	Ccb *ccb;
 	u16int bs, fstat, ms;
 
-	ccb = ((Cc*)(uart->regs))->ccb;
-
 	p = malloc(READSTR);
+	if(p == nil)
+		error(Enomem);
+	ccb = ((Cc*)(uart->regs))->ccb;
 	bs = ccb->bs;
 	fstat = ccb->df;
 	ms = ccb->ms;
@@ -763,6 +764,8 @@ axpalloc(int ctlrno, Pcidev* pcidev)
 	int i, n, timeo;
 
 	ctlr = malloc(sizeof(Ctlr));
+	if(ctlr == nil)
+		error(Enomem);
 	seprint(name, name+sizeof(name), "uartaxp%d", ctlrno);
 	kstrdup(&ctlr->name, name);
 	ctlr->pcidev = pcidev;

+ 3 - 1
sys/src/9/pc/uarti8250.c

@@ -157,8 +157,10 @@ i8250status(Uart* uart, void* buf, long n, long offset)
 	Ctlr *ctlr;
 	uchar ier, lcr, mcr, msr;
 
-	ctlr = uart->regs;
 	p = malloc(READSTR);
+	if(p == nil)
+		error(Enomem);
+	ctlr = uart->regs;
 	mcr = ctlr->sticky[Mcr];
 	msr = csr8r(ctlr, Msr);
 	ier = ctlr->sticky[Ier];

+ 2 - 1
sys/src/9/pc/uartisa.c

@@ -27,9 +27,10 @@ uartisa(int ctlrno, ISAConf* isa)
 
 	uart = malloc(sizeof(Uart));
 	ctlr = i8250alloc(io, isa->irq, BUSUNKNOWN);
-	if(ctlr == nil){
+	if(uart == nil || ctlr == nil){
 		iofree(io);
 		free(uart);
+		free(ctlr);
 		return nil;
 	}
 

+ 2 - 0
sys/src/9/pc/uartpci.c

@@ -29,6 +29,8 @@ uartpci(int ctlrno, Pcidev* p, int barno, int n, int freq, char* name,
 	}
 
 	head = uart = malloc(sizeof(Uart)*n);
+	if(uart == nil)
+		error(Enomem);
 	for(i = 0; i < n; i++){
 		ctlr = i8250alloc(io, p->intl, p->tbdf);
 		io += iosize;

+ 2 - 0
sys/src/9/pc/wavelan.c

@@ -847,6 +847,8 @@ w_ifstat(Ether* ether, void* a, long n, ulong offset)
 		return 0;
 
 	p = malloc(READSTR);
+	if(p == nil)
+		error(Enomem);
 	l = 0;
 
 	PRINTSTAT("Signal: %d\n", ctlr->signal-149);

+ 14 - 0
sys/src/9/port/devaoe.c

@@ -266,6 +266,8 @@ srballoc(ulong sz)
 	Srb *srb;
 
 	srb = malloc(sizeof *srb+sz);
+	if(srb == nil)
+		error(Enomem);
 	srb->dp = srb->data = srb+1;
 	srb->ticksent = MACHP(0)->ticks;
 	return srb;
@@ -277,6 +279,8 @@ srbkalloc(void *db, ulong)
 	Srb *srb;
 
 	srb = malloc(sizeof *srb);
+	if(srb == nil)
+		error(Enomem);
 	srb->dp = srb->data = db;
 	srb->ticksent = MACHP(0)->ticks;
 	return srb;
@@ -1229,6 +1233,8 @@ pstat(Aoedev *d, char *db, int len, int off)
 	char *state, *s, *p, *e;
 
 	s = p = malloc(READSTR);
+	if(s == nil)
+		error(Enomem);
 	e = p + READSTR;
 
 	state = "down";
@@ -1295,6 +1301,8 @@ devlinkread(Chan *c, void *db, int len, int off)
 	l = d->dl + i;
 
 	s = p = malloc(READSTR);
+	if(s == nil)
+		error(Enomem);
 	e = s + READSTR;
 
 	p = seprint(p, e, "addr: ");
@@ -1328,6 +1336,8 @@ topctlread(Chan *, void *db, int len, int off)
 	Netlink *n;
 
 	s = p = malloc(READSTR);
+	if(s == nil)
+		error(Enomem);
 	e = s + READSTR;
 
 	p = seprint(p, e, "debug: %d\n", debug);
@@ -1391,6 +1401,8 @@ configwrite(Aoedev *d, void *db, long len)
 		error(Etoobig);
 	srb = srballoc(len);
 	s = malloc(len);
+	if(s == nil)
+		error(Enomem);
 	memmove(s, db, len);
 	if(waserror()){
 		srbfree(srb);
@@ -1608,6 +1620,8 @@ unitwrite(Chan *c, void *db, long n, vlong off)
 		if(off + n > sizeof d->config)
 			error(Etoobig);
 		buf = malloc(sizeof d->config);
+		if(buf == nil)
+			error(Enomem);
 		if(waserror()){
 			free(buf);
 			nexterror();

+ 2 - 0
sys/src/9/port/devbridge.c

@@ -794,6 +794,8 @@ cachedump(Bridge *b)
 	n *= 51;	// change if print format is changed
 	n += 10;	// some slop at the end
 	buf = malloc(n);
+	if(buf == nil)
+		error(Enomem);
 	p = buf;
 	ep = buf + n;
 	ce = b->cache;

+ 4 - 0
sys/src/9/port/devflash.c

@@ -241,6 +241,8 @@ flashread(Chan *c, void *buf, long n, vlong offset)
 		return n;
 	case Qctl:
 		s = malloc(READSTR);
+		if(s == nil)
+			error(Enomem);
 		if(waserror()){
 			free(s);
 			nexterror();
@@ -476,6 +478,8 @@ addflashcard(char *name, int (*reset)(Flash*))
 	Flashtype *f, **l;
 
 	f = (Flashtype*)malloc(sizeof(*f));
+	if(f == nil)
+		error(Enomem);
 	f->name = name;
 	f->reset = reset;
 	f->next = nil;

+ 36 - 4
sys/src/9/port/devpipe.c

@@ -14,6 +14,7 @@ struct Pipe
 	Pipe	*next;
 	int	ref;
 	ulong	path;
+	long	perm;
 	Queue	*q[2];
 	int	qref[2];
 };
@@ -80,6 +81,7 @@ pipeattach(char *spec)
 	lock(&pipealloc);
 	p->path = ++pipealloc.path;
 	unlock(&pipealloc);
+	p->perm = pipedir[Qdata0].perm;
 
 	mkqid(&c->qid, NETQID(2*p->path, Qdir), 0, QTDIR);
 	c->aux = p;
@@ -116,7 +118,7 @@ pipegen(Chan *c, char*, Dirtab *tab, int ntab, int i, Dir *dp)
 		break;
 	}
 	mkqid(&q, NETQID(NETID(c->qid.path), tab->qid.path), 0, QTFILE);
-	devdir(c, q, tab->name, len, eve, tab->perm, dp);
+	devdir(c, q, tab->name, len, eve, p->perm, dp);
 	return 1;
 }
 
@@ -161,10 +163,10 @@ pipestat(Chan *c, uchar *db, int n)
 		devdir(c, c->qid, ".", 0, eve, DMDIR|0555, &dir);
 		break;
 	case Qdata0:
-		devdir(c, c->qid, "data", qlen(p->q[0]), eve, 0600, &dir);
+		devdir(c, c->qid, "data", qlen(p->q[0]), eve, p->perm, &dir);
 		break;
 	case Qdata1:
-		devdir(c, c->qid, "data1", qlen(p->q[1]), eve, 0600, &dir);
+		devdir(c, c->qid, "data1", qlen(p->q[1]), eve, p->perm, &dir);
 		break;
 	default:
 		panic("pipestat");
@@ -175,6 +177,36 @@ pipestat(Chan *c, uchar *db, int n)
 	return n;
 }
 
+static int
+pipewstat(Chan* c, uchar* db, int n)
+{
+	int m;
+	Dir *dir;
+	Pipe *p;
+
+	p = c->aux;
+	if(strcmp(up->user, eve) != 0)
+		error(Eperm);
+	if(NETTYPE(c->qid.path) == Qdir)
+		error(Eisdir);
+
+	dir = smalloc(sizeof(Dir)+n);
+	if(waserror()){
+		free(dir);
+		nexterror();
+	}
+	m = convM2D(db, n, &dir[0], (char*)&dir[1]);
+	if(m == 0)
+		error(Eshortstat);
+	if(!emptystr(dir[0].uid))
+		error("can't change owner");
+	if(dir[0].mode != ~0UL)
+		p->perm = dir[0].mode;
+	poperror();
+	free(dir);
+	return m;
+}
+
 /*
  *  if the stream doesn't exist, create it
  */
@@ -387,5 +419,5 @@ Dev pipedevtab = {
 	pipewrite,
 	pipebwrite,
 	devremove,
-	devwstat,
+	pipewstat,
 };

+ 5 - 0
sys/src/9/port/devpnp.c

@@ -194,6 +194,11 @@ findcsn(int csn, int create, int dolock)
 	}
 	if(create) {
 		*l = nc = malloc(sizeof(Card));
+		if(nc == nil) {
+			if(dolock)
+				qunlock(&pnp);
+			error(Enomem);
+		}
 		nc->next = c;
 		nc->csn = csn;
 		c = nc;

+ 2 - 0
sys/src/9/port/devproc.c

@@ -934,6 +934,8 @@ procread(Chan *c, void *va, long n, vlong off)
 		if(p->pgrp == nil || p->pid != PID(c->qid))
 			error(Eprocdied);
 		mw = c->aux;
+		if(mw == nil)
+			error(Enomem);
 		if(mw->cddone){
 			qunlock(&p->debug);
 			poperror();

+ 7 - 2
sys/src/9/port/devsd.c

@@ -1086,7 +1086,8 @@ sdread(Chan *c, void *a, long n, vlong off)
 	case Qtopctl:
 		m = 64*1024;	/* room for register dumps */
 		p = buf = malloc(m);
-		assert(p);
+		if(p == nil)
+			error(Enomem);
 		e = p + m;
 		qlock(&devslock);
 		for(i = 0; i < nelem(devs); i++){
@@ -1111,6 +1112,8 @@ sdread(Chan *c, void *a, long n, vlong off)
 		unit = sdev->unit[UNIT(c->qid)];
 		m = 16*1024;	/* room for register dumps */
 		p = malloc(m);
+		if(p == nil)
+			error(Enomem);
 		l = snprint(p, m, "inquiry %.48s\n",
 			(char*)unit->inquiry+8);
 		qlock(&unit->ctl);
@@ -1507,7 +1510,7 @@ Dev sddevtab = {
 	devremove,
 	sdwstat,
 	devpower,
-	sdconfig,
+	sdconfig,	/* probe; only called for pcmcia-like devices */
 };
 
 /*
@@ -1545,6 +1548,8 @@ getnewport(DevConf* dc)
 	Devport *p;
 
 	p = (Devport *)malloc((dc->nports + 1) * sizeof(Devport));
+	if(p == nil)
+		error(Enomem);
 	if(dc->nports > 0){
 		memmove(p, dc->ports, dc->nports * sizeof(Devport));
 		free(dc->ports);

+ 6 - 0
sys/src/9/port/devssl.c

@@ -893,6 +893,8 @@ initDESkey_40(OneWay *w)
 	}
 
 	w->state = malloc(sizeof(DESstate));
+	if(w->state == nil)
+		error(Enomem);
 	if(w->slen >= 16)
 		setupDESstate(w->state, key, w->secret+8);
 	else if(w->slen >= 8)
@@ -929,6 +931,8 @@ initRC4key_40(OneWay *w)
 		w->slen = 5;
 
 	w->state = malloc(sizeof(RC4state));
+	if(w->state == nil)
+		error(Enomem);
 	setupRC4state(w->state, w->secret, w->slen);
 }
 
@@ -948,6 +952,8 @@ initRC4key_128(OneWay *w)
 		w->slen = 16;
 
 	w->state = malloc(sizeof(RC4state));
+	if(w->state == nil)
+		error(Enomem);
 	setupRC4state(w->state, w->secret, w->slen);
 }
 

+ 2 - 0
sys/src/9/port/devuart.c

@@ -513,6 +513,8 @@ uartwrite(Chan *c, void *buf, long n, vlong)
 		break;
 	case Nctlqid:
 		cmd = malloc(n+1);
+		if(cmd == nil)
+			error(Enomem);
 		memmove(cmd, buf, n);
 		cmd[n] = 0;
 		qlock(p);

+ 2 - 0
sys/src/9/port/devwd.c

@@ -77,6 +77,8 @@ wdread(Chan* c, void* a, long n, vlong off)
 			return 0;
 
 		p = malloc(READSTR);
+		if(p == nil)
+			error(Enomem);
 		if(waserror()){
 			free(p);
 			nexterror();

+ 2 - 0
sys/src/9/port/log.c

@@ -22,6 +22,8 @@ logopen(Log *alog)
 			alog->minread = 1;
 		if(alog->buf == nil)
 			alog->buf = malloc(alog->nlog);
+		if(alog->buf == nil)
+			error(Enomem);
 		alog->rptr = alog->buf;
 		alog->end = alog->buf + alog->nlog;
 		alog->len = 0;

+ 9 - 2
sys/src/9/port/master

@@ -9,6 +9,7 @@ C	ce
 D	ssl
 E	sdp
 F	flash
+F	ppcflash
 G	gs1
 I	ip
 K	kprof
@@ -17,8 +18,6 @@ M	mnt
 P	arch
 S	sd
 T	lm78
-U	usb
-V	lml
 V	tv
 X	loopback
 Y	pccard
@@ -40,16 +39,24 @@ r	rtc
 r	µc
 s	srv
 t	uart
+u	usb
+v	dss
+v	lcd
 v	vga
 w	wd
+x	xenstore
 y	i82365
 y	pcmcia
 |	pipe
 ¤	cap
 æ	aoe
 Ι	kbin
+Λ	lml
+α	acpi
 κ	kbmap
 μ	moipv6
+⁲	twsi
+↔	usbcons
 霞	kasumi
 
 α	local use

+ 4 - 0
sys/src/9/port/netif.c

@@ -213,6 +213,8 @@ netifread(Netif *nif, Chan *c, void *a, long n, ulong offset)
 		return readnum(offset, a, n, NETID(c->qid.path), NUMSIZE);
 	case Nstatqid:
 		p = malloc(READSTR);
+		if(p == nil)
+			error(Enomem);
 		j = snprint(p, READSTR, "in: %llud\n", nif->inpackets);
 		j += snprint(p+j, READSTR-j, "link: %d\n", nif->link);
 		j += snprint(p+j, READSTR-j, "out: %llud\n", nif->outpackets);
@@ -233,6 +235,8 @@ netifread(Netif *nif, Chan *c, void *a, long n, ulong offset)
 		return n;
 	case Naddrqid:
 		p = malloc(READSTR);
+		if(p == nil)
+			error(Enomem);
 		j = 0;
 		for(i = 0; i < nif->alen; i++)
 			j += snprint(p+j, READSTR-j, "%2.2ux", nif->addr[i]);

+ 5 - 0
sys/src/9/port/portclock.c

@@ -5,6 +5,7 @@
 #include "fns.h"
 #include "io.h"
 #include "ureg.h"
+#include "../port/error.h"
 
 struct Timers
 {
@@ -214,6 +215,8 @@ timersinit(void)
 	 */
 	todinit();
 	t = malloc(sizeof(*t));
+	if(t == nil)
+		error(Enomem);
 	t->tmode = Tperiodic;
 	t->tt = nil;
 	t->tns = 1000000000/HZ;
@@ -229,6 +232,8 @@ addclock0link(void (*f)(void), int ms)
 
 	/* Synchronize to hztimer if ms is 0 */
 	nt = malloc(sizeof(Timer));
+	if(nt == nil)
+		error(Enomem);
 	if(ms == 0)
 		ms = 1000/HZ;
 	nt->tns = (vlong)ms*1000000LL;