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
1 changed files with 8 additions and 2 deletions

View File

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