Commit f963ef12 authored by Christophe Leroy's avatar Christophe Leroy Committed by Luis Chamberlain

module: Fix "warning: variable 'exit' set but not used"

When CONFIG_MODULE_UNLOAD is not selected, 'exit' is
set but never used.

It is not possible to replace the #ifdef CONFIG_MODULE_UNLOAD by
IS_ENABLED(CONFIG_MODULE_UNLOAD) because mod->exit doesn't exist
when CONFIG_MODULE_UNLOAD is not selected.

And because of the rcu_read_lock_sched() section it is not easy
to regroup everything in a single #ifdef. Let's regroup partially
and add missing #ifdef to completely opt out the use of
'exit' when CONFIG_MODULE_UNLOAD is not selected.
Reported-by: default avatarkernel test robot <lkp@intel.com>
Signed-off-by: default avatarChristophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: default avatarLuis Chamberlain <mcgrof@kernel.org>
parent cfa94c53
...@@ -2939,24 +2939,25 @@ static void cfi_init(struct module *mod) ...@@ -2939,24 +2939,25 @@ static void cfi_init(struct module *mod)
{ {
#ifdef CONFIG_CFI_CLANG #ifdef CONFIG_CFI_CLANG
initcall_t *init; initcall_t *init;
#ifdef CONFIG_MODULE_UNLOAD
exitcall_t *exit; exitcall_t *exit;
#endif
rcu_read_lock_sched(); rcu_read_lock_sched();
mod->cfi_check = (cfi_check_fn) mod->cfi_check = (cfi_check_fn)
find_kallsyms_symbol_value(mod, "__cfi_check"); find_kallsyms_symbol_value(mod, "__cfi_check");
init = (initcall_t *) init = (initcall_t *)
find_kallsyms_symbol_value(mod, "__cfi_jt_init_module"); find_kallsyms_symbol_value(mod, "__cfi_jt_init_module");
exit = (exitcall_t *)
find_kallsyms_symbol_value(mod, "__cfi_jt_cleanup_module");
rcu_read_unlock_sched();
/* Fix init/exit functions to point to the CFI jump table */ /* Fix init/exit functions to point to the CFI jump table */
if (init) if (init)
mod->init = *init; mod->init = *init;
#ifdef CONFIG_MODULE_UNLOAD #ifdef CONFIG_MODULE_UNLOAD
exit = (exitcall_t *)
find_kallsyms_symbol_value(mod, "__cfi_jt_cleanup_module");
if (exit) if (exit)
mod->exit = *exit; mod->exit = *exit;
#endif #endif
rcu_read_unlock_sched();
cfi_module_add(mod, mod_tree.addr_min); cfi_module_add(mod, mod_tree.addr_min);
#endif #endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment