[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20251218-dev-module-init-eexists-modules-docs-v1-2-361569aa782a@samsung.com>
Date: Thu, 18 Dec 2025 21:59:45 +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 2/2] docs: hacking: clarify reserved -EEXIST in
module_init()
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 warning note to clarify what these 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>
---
Documentation/kernel-hacking/hacking.rst | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/Documentation/kernel-hacking/hacking.rst b/Documentation/kernel-hacking/hacking.rst
index 0042776a9e17..2c929ab93143 100644
--- a/Documentation/kernel-hacking/hacking.rst
+++ b/Documentation/kernel-hacking/hacking.rst
@@ -459,6 +459,13 @@ to fail (unfortunately, this has no effect if the module is compiled
into the kernel). This function is called in user context with
interrupts enabled, so it can sleep.
+.. warning::
+
+ The error code ``-EEXIST`` is reserved by the module loader to
+ indicate a module is already loaded. kmod interprets this as success,
+ so ``module_init()`` must never return ``-EEXIST``. Use ``-EBUSY`` or
+ ``-EALREADY`` instead.
+
:c:func:`module_exit()`
-----------------------
--
2.52.0
Powered by blists - more mailing lists