diff --git a/sys/kern/kern_linker.c b/sys/kern/kern_linker.c --- a/sys/kern/kern_linker.c +++ b/sys/kern/kern_linker.c @@ -1226,7 +1226,9 @@ printf("kldunload: attempt to unload file that was" " loaded by the kernel\n"); error = EBUSY; - } else { + } else if (lf->refs > 1) + error = EBUSY; + else { lf->userrefs--; error = linker_file_unload(lf, flags); if (error)