I am writing a driver code for first time. I have checked many resources which state that the initialization function for a kernel module is either init_module() or any another function that is specified using module_init() macro. And this initialization function is called when a kernel module is loaded.

But I could not find any information about what happens when initialization function doesn't exist in a Loadable kernel module and is tried to load.

What would be the scenario if the kernel module is in-tree and doesn't have initialization function??

---Thanks in advance..

1 Answer 1


Modules don’t need to have an initialisation function, do_init_module handles its absence:

        /* Start the module */
        if (mod->init != NULL)
                ret = do_one_initcall(mod->init);

Such modules can be unloaded without an exit function either (as opposed to modules with an initialisation function, which are permanent if they don’t have an exit function).

When modules are built-in, initialisation functions become __initcall functions which are identified at link time; their absence doesn’t cause any problem either.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .