From: Daniel Gomez <da.gomez@kernel.org>
To: Luis Chamberlain <mcgrof@kernel.org>,
Petr Pavlu <petr.pavlu@suse.com>,
Daniel Gomez <da.gomez@kernel.org>,
Sami Tolvanen <samitolvanen@google.com>,
Aaron Tomlin <atomlin@atomlin.com>,
Jonathan Corbet <corbet@lwn.net>,
Lucas De Marchi <demarchi@kernel.org>
Cc: linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org, Daniel Gomez <da.gomez@samsung.com>
Subject: [PATCH 2/2] docs: hacking: clarify reserved -EEXIST in module_init()
Date: Thu, 18 Dec 2025 21:59:45 +0100 [thread overview]
Message-ID: <20251218-dev-module-init-eexists-modules-docs-v1-2-361569aa782a@samsung.com> (raw)
In-Reply-To: <20251218-dev-module-init-eexists-modules-docs-v1-0-361569aa782a@samsung.com>
From: Daniel Gomez <da.gomez@samsung.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@samsung.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
prev parent reply other threads:[~2025-12-18 21:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-18 20:59 [PATCH 0/2] module: add -EEXIST module_init() reservation docs Daniel Gomez
2025-12-18 20:59 ` [PATCH 1/2] module: add -EEXIST documentation Daniel Gomez
2025-12-18 20:59 ` Daniel Gomez [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251218-dev-module-init-eexists-modules-docs-v1-2-361569aa782a@samsung.com \
--to=da.gomez@kernel.org \
--cc=atomlin@atomlin.com \
--cc=corbet@lwn.net \
--cc=da.gomez@samsung.com \
--cc=demarchi@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=petr.pavlu@suse.com \
--cc=samitolvanen@google.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).