The structure for a kernel module is like so: 52 /* 53 * Struct for registering modules statically via SYSINIT. 54 */ 55 typedef struct moduledata { 56 const char *name; /* module name */ 57 modeventhand_t evhand; /* event handler */ 58 void *priv; /* extra data */ 59 } moduledata_t; The documentation doesn't note that evhand can be NULL though (and if it's NULL then modevent_nop will be used in lieu of evhand): $ grep -r evhand /sys/kern/ /sys/kern/kern_module.c: " %d\n", data->name, (void *)data->evhand, data->priv, /sys/kern/kern_module.c: newmod->handler = data->evhand ? data->evhand : modevent_nop; $ I looked at the examples in /usr/share/examples/kld and they didn't provide an example that did this either.
Created attachment 228271 [details] module.9 patch Mention what happens when the event handler function is NULL.
A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=c5e0492ae81e4b0d7946ccfbedb434a9c4071256 commit c5e0492ae81e4b0d7946ccfbedb434a9c4071256 Author: Felix Johnson <felix.the.red@gmail.com> AuthorDate: 2021-11-11 06:28:45 +0000 Commit: Guangyuan Yang <ygy@FreeBSD.org> CommitDate: 2021-11-11 06:32:54 +0000 module(9): Document that evhand can be NULL PR: 192250 MFC after: 3 days Reported by: ngie share/man/man9/module.9 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
A commit in branch stable/13 references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=109330155000bfec215ee39148254d2a0b628798 commit 109330155000bfec215ee39148254d2a0b628798 Author: Felix Johnson <felix.the.red@gmail.com> AuthorDate: 2021-11-11 06:28:45 +0000 Commit: Guangyuan Yang <ygy@FreeBSD.org> CommitDate: 2021-11-14 06:37:20 +0000 module(9): Document that evhand can be NULL PR: 192250 Reported by: ngie (cherry picked from commit c5e0492ae81e4b0d7946ccfbedb434a9c4071256) share/man/man9/module.9 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)