⬢ DragonFlyBSD Kernel Audit
DF-3234 / fix.diff
← back to finding ↓ download raw
--- a/sys/vfs/ext2fs/ext2_balloc.c
+++ b/sys/vfs/ext2fs/ext2_balloc.c
@@ -132,9 +132,11 @@
 			/*
 			 * If the newly allocated block exceeds 32-bit limit,
 			 * we can not use it in file block maps.
 			 */
 			if (newb > UINT_MAX)
+				EXT2_UNLOCK(ump);
+				ext2_blkfree(ip, newb, fs->e2fs_bsize);
 				return (EFBIG);
@@ -166,9 +168,11 @@
 		if ((error = ext2_alloc(ip, lbn, pref, fs->e2fs_bsize, cred,
 		    &newb)))
 			return (error);
 		if (newb > UINT_MAX)
+			EXT2_UNLOCK(ump);
+			ext2_blkfree(ip, newb, fs->e2fs_bsize);
 			return (EFBIG);
@@ -213,9 +217,11 @@
 		}
 		if (newb > UINT_MAX) {
+			EXT2_UNLOCK(ump);
+			ext2_blkfree(ip, newb, fs->e2fs_bsize);
 			brelse(bp);
 			return (EFBIG);
 		}
@@ -256,9 +263,11 @@
 		}
 		if (newb > UINT_MAX) {
+			EXT2_UNLOCK(ump);
+			ext2_blkfree(ip, newb, fs->e2fs_bsize);
 			brelse(bp);
 			return (EFBIG);
 		}