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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Daniel Gomez <da.gomez@xxxxxxxxxxx>

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

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) {

-- 
2.39.2






[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux