git: 9front

Download patch

ref: 69c877e2d7aa0a391d1b7169827f6c922f5cf777
parent: 8047c827640de8b848e1ec9e635478c1467300e7
author: cinap_lenrek <cinap_lenrek@gmx.de>
date: Fri Nov 16 14:55:58 EST 2012

hjfs: fix potential deadlock in putloc()

--- a/sys/src/cmd/hjfs/fs1.c
+++ b/sys/src/cmd/hjfs/fs1.c
@@ -428,11 +428,17 @@
 	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;
--