Skip to content

Commit f963ef1

Browse files
chleroymcgrof
authored andcommitted
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: kernel test robot <[email protected]> Signed-off-by: Christophe Leroy <[email protected]> Signed-off-by: Luis Chamberlain <[email protected]>
1 parent cfa94c5 commit f963ef1

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

kernel/module/main.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2939,24 +2939,25 @@ static void cfi_init(struct module *mod)
29392939
{
29402940
#ifdef CONFIG_CFI_CLANG
29412941
initcall_t *init;
2942+
#ifdef CONFIG_MODULE_UNLOAD
29422943
exitcall_t *exit;
2944+
#endif
29432945

29442946
rcu_read_lock_sched();
29452947
mod->cfi_check = (cfi_check_fn)
29462948
find_kallsyms_symbol_value(mod, "__cfi_check");
29472949
init = (initcall_t *)
29482950
find_kallsyms_symbol_value(mod, "__cfi_jt_init_module");
2949-
exit = (exitcall_t *)
2950-
find_kallsyms_symbol_value(mod, "__cfi_jt_cleanup_module");
2951-
rcu_read_unlock_sched();
2952-
29532951
/* Fix init/exit functions to point to the CFI jump table */
29542952
if (init)
29552953
mod->init = *init;
29562954
#ifdef CONFIG_MODULE_UNLOAD
2955+
exit = (exitcall_t *)
2956+
find_kallsyms_symbol_value(mod, "__cfi_jt_cleanup_module");
29572957
if (exit)
29582958
mod->exit = *exit;
29592959
#endif
2960+
rcu_read_unlock_sched();
29602961

29612962
cfi_module_add(mod, mod_tree.addr_min);
29622963
#endif

0 commit comments

Comments
 (0)