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
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@samsung.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