git: 9front

Download patch

ref: 4a48f151b74da831bb8451b29d4e031e2322005f
parent: 32bda0889df63c4c9fa914fe35909cc8e2c41609
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sat Feb 6 08:33:27 EST 2021

pc, pc64: warn when running out of conf.mem[] entries in meminit()

--- a/sys/src/9/pc/memory.c
+++ b/sys/src/9/pc/memory.c
@@ -568,13 +568,16 @@
 		size = memmapsize(base, BY2PG) & ~(BY2PG-1);
 		if(size == 0)
 			continue;
+		if(cm >= &conf.mem[nelem(conf.mem)]){
+			print("meminit: out of entries, loosing: %#p (%llud)\n", base, (uvlong)size);
+			continue;
+		}
 		cm->base = memmapalloc(base, size, BY2PG, MemRAM);
 		if(cm->base == -1)
 			continue;
 		base = cm->base;
 		cm->npage = size/BY2PG;
-		if(++cm >= &conf.mem[nelem(conf.mem)])
-			break;
+		cm++;
 	}
 
 	if(0) memmapdump();
--