git: 9front

Download patch

ref: b7dc7d6f31b15a0eb28ec96df2f169fa0165332e
parent: a870bde050a3d09d8f1dc0d59fc6376cbb1cdadd
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat Jun 13 13:50:26 EDT 2015

kernel: dont use smalloc() to allocate pte array in ibrk()

when we'r out of kernel memory, it is probably better to
let that alloc fail instead of hanging while holding the
segment qlock.

--- a/sys/src/9/port/segment.c
+++ b/sys/src/9/port/segment.c
@@ -437,7 +437,11 @@
 	}
 	mapsize = ROUND(newsize, PTEPERTAB)/PTEPERTAB;
 	if(mapsize > s->mapsize){
-		map = smalloc(mapsize*sizeof(Pte*));
+		map = malloc(mapsize*sizeof(Pte*));
+		if(map == nil){
+			qunlock(s);
+			error(Enomem);
+		}
 		memmove(map, s->map, s->mapsize*sizeof(Pte*));
 		if(s->map != s->ssegmap)
 			free(s->map);
--