summaryrefslogtreecommitdiff
path: root/sys/src/9/pc/ethervirtio.c
diff options
context:
space:
mode:
authoraiju <devnull@localhost>2017-06-12 11:25:12 +0000
committeraiju <devnull@localhost>2017-06-12 11:25:12 +0000
commit48c5da7a64804bf649ff815c778064dfe8c59711 (patch)
tree4e055f9fed88d62565cb499c20e89bc8af46f159 /sys/src/9/pc/ethervirtio.c
parent45411c31dc8d2e7a1b5d572acbca38581f01f242 (diff)
ethervirtio: report correct length; fail gracefully if we can't initialize queues
Diffstat (limited to 'sys/src/9/pc/ethervirtio.c')
-rw-r--r--sys/src/9/pc/ethervirtio.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/sys/src/9/pc/ethervirtio.c b/sys/src/9/pc/ethervirtio.c
index 170425a0e..f62dd9a71 100644
--- a/sys/src/9/pc/ethervirtio.c
+++ b/sys/src/9/pc/ethervirtio.c
@@ -324,7 +324,7 @@ rxproc(void *v)
blocks[i] = nil;
- b->wp = b->rp + u->len;
+ b->wp = b->rp + u->len - VheaderSize;
etheriq(edev, b, 1);
q->lastused++;
}
@@ -591,13 +591,21 @@ pciprobe(int typ)
for(i=0; i<nelem(c->queue); i++){
outs(c->port+Qselect, i);
n = ins(c->port+Qsize);
- if(n == 0 || (n & (n-1)) != 0)
+ if(n == 0 || (n & (n-1)) != 0){
+ if(i < 2)
+ print("ethervirtio: queue %d has invalid size %d\n", i, n);
break;
+ }
if(initqueue(&c->queue[i], n) < 0)
break;
coherence();
outl(c->port+Qaddr, PADDR(c->queue[i].desc)/VBY2PG);
}
+ if(i < 2){
+ print("ethervirtio: no queues\n");
+ free(c);
+ continue;
+ }
c->nqueue = i;
if(h == nil)