ref: 163dccbac04a3c9ab132005ebb4a96a0e0baec0b
parent: d18440d992243c8e2f5a866d074a597c1a03754f
author: cinap_lenrek <[email protected]>
date: Tue Mar 14 15:32:20 EDT 2017
upas/fs: make sure mbox is locked during msgdecref() in rclunk()
--- a/sys/src/cmd/upas/fs/fs.c
+++ b/sys/src/cmd/upas/fs/fs.c
@@ -1442,17 +1442,17 @@
/* coherence(); */
f->fid = -1;
f->open = 0;
- if(f->mtop){
- qlock(f->mb);
- msgdecref(f->mb, f->mtop);
- qunlock(f->mb);
- }
+ mb = f->mb;
+ if(mb != nil)
+ qlock(mb);
+ if(f->mtop)
+ msgdecref(mb, f->mtop);
if(f->m)
- msgdecref(f->mb, gettopmsg(f->mb, f->m));
+ msgdecref(mb, gettopmsg(mb, f->m));
f->m = f->mtop = nil;
- mb = f->mb;
if(mb != nil){
f->mb = nil;
+ qunlock(mb);
assert(mb->refs > 0);
qlock(&mbllock);
mboxdecref(mb);