[kmod] module: fix error path in kmod_module_probe_insert_module()
diff mbox series

Message ID 20190526092512.993-1-brgl@bgdev.pl
State New
Headers show
Series
  • [kmod] module: fix error path in kmod_module_probe_insert_module()
Related show

Commit Message

Bartosz Golaszewski May 26, 2019, 9:25 a.m. UTC
From: Bartosz Golaszewski <bgolaszewski@baylibre.com>

The documentation says that kmod_module_probe_insert_module() will
return >0 if "stopped by a reason given in @flags" but it returns a
negative value if KMOD_PROBE_FAIL_ON_LOADED flag is passed and the
relevant module is already loaded. Fix the error path by using a
positive error value where required.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
---
 libkmod/libkmod-module.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Patch
diff mbox series

diff --git a/libkmod/libkmod-module.c b/libkmod/libkmod-module.c
index bffe715..a3afaba 100644
--- a/libkmod/libkmod-module.c
+++ b/libkmod/libkmod-module.c
@@ -1253,7 +1253,7 @@  KMOD_EXPORT int kmod_module_probe_insert_module(struct kmod_module *mod,
 	if (!(flags & KMOD_PROBE_IGNORE_LOADED)
 					&& module_is_inkernel(mod)) {
 		if (flags & KMOD_PROBE_FAIL_ON_LOADED)
-			return -EEXIST;
+			return EEXIST;
 		else
 			return 0;
 	}
@@ -1304,7 +1304,7 @@  KMOD_EXPORT int kmod_module_probe_insert_module(struct kmod_module *mod,
 						&& module_is_inkernel(m)) {
 			DBG(mod->ctx, "Ignoring module '%s': already loaded\n",
 								m->name);
-			err = -EEXIST;
+			err = EEXIST;
 			goto finish_module;
 		}
 
@@ -1340,14 +1340,14 @@  finish_module:
 		 * been loaded between the check and the moment we try to
 		 * insert it.
 		 */
-		if (err == -EEXIST && m == mod &&
+		if (err == EEXIST && m == mod &&
 				(flags & KMOD_PROBE_FAIL_ON_LOADED))
 			break;
 
 		/*
 		 * Ignore errors from softdeps
 		 */
-		if (err == -EEXIST || !m->required)
+		if (err == EEXIST || !m->required)
 			err = 0;
 
 		else if (err < 0)