Skip to content

Commit

Permalink
module: avoid double ref drop on ro_after_init failure
Browse files Browse the repository at this point in the history
Ensure the module reference is only dropped once in case we fail at
MOD_RO_AFTER_INIT case.

Signed-off-by: Daniel Gomez <da.gomez@samsung.com>
  • Loading branch information
dkruces authored and mcgrof committed Nov 26, 2024
1 parent 79fe2d2 commit 84e5ed0
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions kernel/module/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -2849,8 +2849,6 @@ static noinline int do_init_module(struct module *mod)
ftrace_free_mem(mod, mod->mem[MOD_INIT_TEXT].base,
mod->mem[MOD_INIT_TEXT].base + mod->mem[MOD_INIT_TEXT].size);
mutex_lock(&module_mutex);
/* Drop initial reference. */
module_put(mod);
trim_init_extable(mod);
#ifdef CONFIG_KALLSYMS
/* Switch to core kallsyms now init is done: kallsyms may be walking! */
Expand All @@ -2859,6 +2857,8 @@ static noinline int do_init_module(struct module *mod)
ret = module_enable_rodata_ro(mod, true);
if (ret)
goto fail_mutex_unlock;
/* Drop initial reference. */
module_put(mod);
mod_tree_remove_init(mod);
module_arch_freeing_init(mod);
for_class_mod_mem_type(type, init) {
Expand Down

0 comments on commit 84e5ed0

Please sign in to comment.