DragonFlyBSD Kernel Audit
DF-2739 / fix.diff
← back to finding ↓ download raw
--- a/sys/kern/kern_linker.c
+++ b/sys/kern/kern_linker.c
@@ -514,8 +514,11 @@
 	if ((error = module_unload(mod)) != 0) {
 	    KLD_DPF(FILE, ("linker_file_unload: module %p vetoes unload\n",
 			   mod));
+	    /*
+	     * The unload failed, so the caller's reference must
+	     * survive.  Do NOT drop it here.
+	     */
 	    lockmgr(&llf_lock, LK_RELEASE);
-	    file->refs--;
 	    goto out;
 	}
 	module_release(mod);