⬢ DragonFlyBSD Kernel Audit
DF-3004 / fix.diff
← back to finding ↓ download raw
--- a/sys/vfs/hammer/hammer_object.c
+++ b/sys/vfs/hammer/hammer_object.c
@@ -852,7 +852,12 @@
 	 */
 	if (error == 0) {
 		if (ip) {
-			--ip->ino_data.nlinks;	/* do before we might block */
+			if (ip->ino_data.nlinks > 0) {
+				--ip->ino_data.nlinks;
+			} else {
+				hkprintf("nlinks underflow on obj %016jx\n",
+					 (intmax_t)ip->obj_id);
+			}
 			ip->ino_data.ctime = trans->time;
 		}
 		dip->ino_data.mtime = trans->time;