kernel module event handler question

Thomas E. Spanjaard tgen at netphreax.net
Sat Jun 17 06:09:34 PDT 2006


YONETANI Tomokazu wrote:
If the event handler in a kernel module returns an error upon registration,
isn't the module supposed to be removed from the kldstat's list?
I wrote a simple kernel module(attached) which always returns EOPNOTSUPP
for MOD_LOAD event.  It adds two sysctl nodes debug.test and debug.test_int.
Reading from or writing to debug.test calls test_sysctl_proc() function.
When loaded, although module_register_init prints an error message, the
modules sits there, and I can even set different values to debug.test.
Is this an expected behavior?  Do I need to do something special to
unregister my kernel module when something went wrong?
I guess the reference count of the module is still >0. in 
module_register_init(), mod_release() is called on the module if an 
error occurred, but it seems the reference count is still >0 after the 
call. This seems wrong, since a module which fails loading can never be 
useful. Also, you do see the 'kldunload'ing OK' printf()? And the error 
from module_register_init()?

Cheers,
--
        Thomas E. Spanjaard
        tgen at xxxxxxxxxxxxx
Attachment:
signature.asc
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pgp00004.pgp
Type: application/octet-stream
Size: 186 bytes
Desc: "Description: OpenPGP digital signature"
URL: <http://lists.dragonflybsd.org/pipermail/kernel/attachments/20060617/35453f0b/attachment-0014.obj>


More information about the Kernel mailing list