module: fix clang CFI with MODULE_UNLOAD=n

When CONFIG_MODULE_UNLOAD is disabled, the module->exit member
is not defined, causing a build failure:

kernel/module.c:4493:8: error: no member named 'exit' in 'struct module'
                mod->exit = *exit;

add an #ifdef block around this.

Fixes: cf68fffb66d6 ("add support for Clang CFI")
Acked-by: Kees Cook <>
Reviewed-by: Sami Tolvanen <>
Reviewed-by: Miroslav Benes <>
Signed-off-by: Arnd Bergmann <>
Signed-off-by: Jessica Yu <>
1 file changed