Add wrapper functions for acquiring module_mutex so that the locking can be implicitly compiled out when CONFIG_MODULES is not enabled.
Cc: Andi Kleen <[email protected]> Suggested-by: Masami Hiramatsu <[email protected]> Signed-off-by: Jarkko Sakkinen <[email protected]> --- include/linux/module.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/linux/module.h b/include/linux/module.h index 2e6670860d27..8850b9692b8f 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -705,6 +705,16 @@ static inline bool is_livepatch_module(struct module *mod) bool is_module_sig_enforced(void); void set_module_sig_enforced(void); +static inline void lock_modules(void) +{ + mutex_lock(&module_mutex); +} + +static inline void unlock_modules(void) +{ + mutex_unlock(&module_mutex); +} + #else /* !CONFIG_MODULES... */ static inline struct module *__module_address(unsigned long addr) @@ -852,6 +862,14 @@ void *dereference_module_function_descriptor(struct module *mod, void *ptr) return ptr; } +static inline void lock_modules(void) +{ +} + +static inline void unlock_modules(void) +{ +} + #endif /* CONFIG_MODULES */ #ifdef CONFIG_SYSFS -- 2.25.1

