Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

module: Override -EEXIST module return

The -EEXIST errno is reserved by the module loading functionality. When
userspace calls [f]init_module(), it expects a -EEXIST to mean that the
module is already loaded in the kernel. If module_init() returns it,
that is not true anymore.

Override the error when returning to userspace: it doesn't make sense to
change potentially long error propagation call chains just because it's
will end up as the return of module_init().

Closes: https://lore.kernel.org/all/aKLzsAX14ybEjHfJ@orbyte.nwl.cc/
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: Aaron Tomlin <atomlin@atomlin.com>
Cc: Petr Pavlu <petr.pavlu@suse.com>
Cc: Daniel Gomez <da.gomez@samsung.com>
Cc: Phil Sutter <phil@nwl.cc>
Cc: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Lucas De Marchi <demarchi@kernel.org>
[Sami: Fixed a typo.]
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>

authored by

Lucas De Marchi and committed by
Sami Tolvanen
743f8cae 3b1299f2

+8
+8
kernel/module/main.c
··· 3105 3105 if (mod->init != NULL) 3106 3106 ret = do_one_initcall(mod->init); 3107 3107 if (ret < 0) { 3108 + /* 3109 + * -EEXIST is reserved by [f]init_module() to signal to userspace that 3110 + * a module with this name is already loaded. Use something else if the 3111 + * module itself is returning that. 3112 + */ 3113 + if (ret == -EEXIST) 3114 + ret = -EBUSY; 3115 + 3108 3116 goto fail_free_freeinit; 3109 3117 } 3110 3118 if (ret > 0) {