shithub: riscv

Download patch

ref: 37b9ab5a043e45a68979632c177e11af7a439027
parent: 779f6cb3b8a304677c293e5deff3305336681997
author: aiju <devnull@localhost>
date: Wed Jun 21 05:59:32 EDT 2017

devvmx: error handling in clearmeminfo

--- a/sys/src/9/pc/devvmx.c
+++ b/sys/src/9/pc/devvmx.c
@@ -703,9 +703,14 @@
 		q = strchr(p, '\n');
 		if(q == 0) break;
 		*q = 0;
-		if(mp == nil)
+		if(mp == nil){
 			mp = malloc(sizeof(VmMem));
+			if(mp == nil)
+				error(Enomem);
+		}
+		memset(mp, 0, sizeof(VmMem));
 		if(waserror()){
+			putseg(mp->seg);
 			free(mp->name);
 			free(mp);
 			nexterror();
@@ -714,7 +719,6 @@
 		p = q + 1;
 		if(rc == 0) goto next;
 		if(rc != 4 && rc != 6) error("number of fields wrong");
-		memset(mp, 0, sizeof(VmMem));
 		for(q = f[0]; *q != 0; q++)
 			switch(*q){
 			case 'r': if((mp->attr & 1) != 0) goto tinval; mp->attr |= 1; break;