From 84ddc4cd4b0fae049f9fa68ee586fbc53cfa2f83 Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Fri, 16 Nov 2012 19:55:58 +0100 Subject: [PATCH] hjfs: fix potential deadlock in putloc() --- sys/src/cmd/hjfs/fs1.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sys/src/cmd/hjfs/fs1.c b/sys/src/cmd/hjfs/fs1.c index b059a39ff..e7a116ba8 100644 --- a/sys/src/cmd/hjfs/fs1.c +++ b/sys/src/cmd/hjfs/fs1.c @@ -428,11 +428,17 @@ putloc(Fs *fs, Loc *l, int loop) while(loop && l != nil && l->ref <= 1){ freeit: if((l->flags & LGONE) != 0){ + /* + * safe to unlock here, the file is gone and + * we'r the last reference. + */ + qunlock(&fs->loctree); b = getbuf(fs->d, l->blk, TDENTRY, 0); if(b != nil){ delete(fs, l, b); putbuf(b); } + qlock(&fs->loctree); } l->cnext->cprev = l->cprev; l->cprev->cnext = l->cnext;