How to use linux kernel’s find_module() function?
The documentation says “must hold module_mutex”.
- Does that mean that I should acquire
a lock in my module code before
searching for a pointer to another? - When this mutex is locked by
non-module kernel code?
Context
I’m debugging a set of kernel modules working together.
Module A call functions of module B. At some point in function C of module A a use count of module B goes invalid. I’ve determined that this is not happening in function of module B. I’d like to debug use count of module B from C. To do this I’m going to use find_module() to obtain a pointer to B.
I would suggest being a little more defensive in your code:
module_mutex is acquired by the kernel in various operations on modules. All of them are in /kernel/module.c and are: