[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20251218-dev-module-init-eexists-modules-docs-v1-1-361569aa782a@samsung.com>
Date: Thu, 18 Dec 2025 21:59:44 +0100
From: Daniel Gomez <da.gomez@...nel.org>
To: Luis Chamberlain <mcgrof@...nel.org>, Petr Pavlu <petr.pavlu@...e.com>,
Daniel Gomez <da.gomez@...nel.org>, Sami Tolvanen <samitolvanen@...gle.com>,
Aaron Tomlin <atomlin@...mlin.com>, Jonathan Corbet <corbet@....net>,
Lucas De Marchi <demarchi@...nel.org>
Cc: linux-modules@...r.kernel.org, linux-kernel@...r.kernel.org,
linux-doc@...r.kernel.org, Daniel Gomez <da.gomez@...sung.com>
Subject: [PATCH 1/2] module: add -EEXIST documentation
From: Daniel Gomez <da.gomez@...sung.com>
The error code -EEXIST is reserved by the kernel module loader to
indicate that a module with the same name is already loaded. Add a
comment to clarify what this means for module authors and maintainers
to ensure the module_init() path return error do not conflict with the
reserved one.
Signed-off-by: Daniel Gomez <da.gomez@...sung.com>
---
kernel/module/main.c | 8 ++++++++
1 file changed, 8 insertions(+)
diff --git a/kernel/module/main.c b/kernel/module/main.c
index a8394d81174f..655a780981d3 100644
--- a/kernel/module/main.c
+++ b/kernel/module/main.c
@@ -3038,6 +3038,14 @@ static noinline int do_init_module(struct module *mod)
if (mod->init != NULL)
ret = do_one_initcall(mod->init);
if (ret < 0) {
+ /*
+ * -EEXIST is reserved by the module loader to mean "already loaded". kmod
+ * interprets this as success, hiding real module failures. Override with
+ * -EBUSY and warn.
+ *
+ * Module authors: use -EBUSY or -EALREADY instead of -EEXIST.
+ * See Documentation/kernel-hacking/hacking.rst
+ */
if (ret == -EEXIST) {
pr_warn("%s: init suspiciously returned -EEXIST: Overriding with -EBUSY\n",
mod->name);
--
2.52.0
Powered by blists - more mailing lists