module_register_init fails, but driver is still loaded?
Garrett Cooper
yanegomi at gmail.com
Thu Aug 4 16:23:16 UTC 2011
Hi hackers,
I noticed that if anything fails while initializing a driver, the
driver stays attached to the kernel as a module instead of being
kicked when all references to the driver go to 0. Is this desired
behavior (it doesn't seem like it, but I can see potential pros and
cons of kicking the driver out of the kernel immediately when a
failure state occurs)? I've seen this on 7.2 ~ 9-CURRENT. Example
sourcecode and invocation attached below.
Thanks!
-Garrett
/* bad_module.c */
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/module.h>
#define MODULE_NAME "bad_module"
static int
load(module_t m, int what, void *arg)
{
return (EINVAL);
}
static moduledata_t bad_module_mod = {
MODULE_NAME,
&load,
NULL,
};
DECLARE_MODULE(bad_module, bad_module_mod, SI_SUB_KLD, SI_ORDER_ANY);
MODULE_VERSION(bad_module, 1);
/* Makefile */
KMOD= bad_module
SRCS= bad_module.c
.include <bsd.kmod.mk>
$ sudo kldload ./bad_driver.ko
$ dmesg | tail -n 1
module_register_init: MOD_LOAD (bad_module, 0xffffffff80a53000, 0) error 22
$ kldstat -v | grep bad_driver
5 1 0xffffffff80a53000 de bad_driver.ko
$ sudo kldunload ./bad_driver.ko
$ kldstat -v | grep bad_driver
$
More information about the freebsd-hackers
mailing list