[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20241108-modules-ro_after_init-v3-2-6dd041b588a5@samsung.com>
Date: Fri, 08 Nov 2024 17:12:14 +0100
From: Daniel Gomez via B4 Relay <devnull+da.gomez.samsung.com@...nel.org>
To: Luis Chamberlain <mcgrof@...nel.org>, Petr Pavlu <petr.pavlu@...e.com>,
Sami Tolvanen <samitolvanen@...gle.com>,
Christophe Leroy <christophe.leroy@...roup.eu>,
Thomas Gleixner <tglx@...utronix.de>, Jinjie Ruan <ruanjinjie@...wei.com>,
Jens Axboe <axboe@...nel.dk>
Cc: "Daniel Gomez (Samsung)" <d+samsung@...ces.com>,
linux-modules@...r.kernel.org, linux-kernel@...r.kernel.org,
Daniel Gomez <da.gomez@...sung.com>
Subject: [PATCH RFC v3 2/4] module: avoid double ref drop on ro_after_init
failure
From: Daniel Gomez <da.gomez@...sung.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@...sung.com>
---
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
Powered by blists - more mailing lists