diff mbox series

[RFC,v3,2/4] module: avoid double ref drop on ro_after_init failure

Message ID 20241108-modules-ro_after_init-v3-2-6dd041b588a5@samsung.com (mailing list archive)
State New
Headers show
Series module: refactor ro_after_init failure path | expand

Checks

Context Check Description
mcgrof/vmtest-modules-next-PR success PR summary
mcgrof/vmtest-modules-next-VM_Test-5 success Logs for setup / Setup kdevops environment
mcgrof/vmtest-modules-next-VM_Test-0 success Logs for Run CI tests
mcgrof/vmtest-modules-next-VM_Test-3 fail Logs for cleanup / Archive results and cleanup
mcgrof/vmtest-modules-next-VM_Test-4 success Logs for setup / Setup kdevops environment
mcgrof/vmtest-modules-next-VM_Test-2 success Logs for setup / Setup kdevops environment
mcgrof/vmtest-modules-next-VM_Test-1 success Logs for cleanup / Archive results and cleanup

Commit Message

Daniel Gomez via B4 Relay Nov. 8, 2024, 4:12 p.m. UTC
From: Daniel Gomez <da.gomez@samsung.com>

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>
---
 kernel/module/main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
diff mbox series

Patch

diff --git a/kernel/module/main.c b/kernel/module/main.c
index e0b2a8d9e324..35a50ded64a6 100644
--- a/kernel/module/main.c
+++ b/kernel/module/main.c
@@ -2941,8 +2941,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! */
@@ -2951,6 +2949,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) {