kern: fix proc ref counting in procread

This commit is contained in:
Giacomo Tesio 2017-11-21 00:50:26 +01:00
parent df9c0d8fe4
commit 726217c766

View File

@ -857,6 +857,7 @@ procread(Chan *c, void *va, long n, int64_t off)
return n;
case Qsyscall:
psdecref(p);
return qread(c->aux, va, n);
case Qmem:
@ -949,13 +950,18 @@ procread(Chan *c, void *va, long n, int64_t off)
rptr = (uint8_t*)&p->fpsave;
rsize = sizeof(FPsave);
regread:
if(rptr == nil)
if(rptr == nil){
psdecref(p);
error(Enoreg);
if(offset >= rsize)
}
if(offset >= rsize){
psdecref(p);
return 0;
}
if(offset+n > rsize)
n = rsize - offset;
memmove(a, rptr+offset, n);
psdecref(p);
return n;
case Qstatus: