DragonFlyBSD Kernel Audit
DF-0839 / fix.diff
← back to finding ↓ download raw
diff --git a/sys/vfs/hammer/hammer_ioctl.c b/sys/vfs/hammer/hammer_ioctl.c
--- a/sys/vfs/hammer/hammer_ioctl.c
+++ b/sys/vfs/hammer/hammer_ioctl.c
@@ -647,8 +647,18 @@
 	    ver->cur_version >= HAMMER_VOL_VERSION_FOUR) {
 		hkprintf("upgrade undo to version 4\n");
 		error = hammer_upgrade_undo_4(trans);
-		if (error)
+		if (error) {
+			/*
+			 * Restore the in-memory version and release the
+			 * sync_lock and finalize_lock that we acquired
+			 * above, before jumping to the cleanup label.
+			 * Otherwise both locks are permanently leaked.
+			 */
+			hmp->version = over;
+			hammer_sync_unlock(trans);
+			hammer_unlock(&hmp->flusher.finalize_lock);
 			goto failed;
+		}
 	}
 
 	/*