0xdeadbeef
0xdeadbeef

Reputation: 25

Will the Kernel module load when there is no initialization function?

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..

Upvotes: 0

Views: 611

Answers (1)

stark
stark

Reputation: 13189

In the routine do_init_module, it tests whether an init routine is provided. If not, it just skips the call. See https://elixir.bootlin.com/linux/v3.10.108/source/kernel/module.c#L3092

if (mod->init != NULL)
    ret = do_one_initcall(mod->init);

Upvotes: 2

Related Questions