Browse Source

Allocate exchange buffers with malloc, not on stack. Use PCI device name
for the virtqeue device file.

Signed-off-by: golubovsky <golubovsky@gmail.com>

golubovsky 7 years ago
parent
commit
2d4313616b
1 changed files with 7 additions and 2 deletions
  1. 7 2
      sys/src/9/port/devvcon.c

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

@@ -59,7 +59,11 @@ rwcommon(Vqctl *d, void *va, int32_t n, int qidx)
 		error("virtcon: queue low");
 		return -1;
 	}
-	uint8_t buf[n];
+	uint8_t *buf = malloc(n);
+	if(buf==nil) {
+		error("devvcon: no memory to allocate the exchange buffer");
+		return -1;
+	}
 	if(qidx) {
 		memmove(buf, va, n);
 	}
@@ -73,6 +77,7 @@ rwcommon(Vqctl *d, void *va, int32_t n, int qidx)
 		memmove(va, buf, n);
 	}
 	reldescr(vq, 1, descr);
+	free(buf);
 	return (rc >= 0)?n:rc;
 }
 
@@ -103,7 +108,7 @@ vcongen(Chan *c, char *d, Dirtab* dir, int i, int s, Dir *dp)
 		}
 		if(s >= nvcon)
 			return -1;
-		snprint(up->genbuf, sizeof up->genbuf, "vcons%d", s);
+		snprint(up->genbuf, sizeof up->genbuf, vcons[s]->devname);
 		q = (Qid) {QID(s, Qvcpipe), 0, 0};
 		devdir(c, q, up->genbuf, 0, eve, 0666, dp);
 		return 1;