linux-modules.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bartosz Golaszewski <brgl@bgdev.pl>
To: Lucas De Marchi <lucas.demarchi@intel.com>
Cc: linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org,
	Bartosz Golaszewski <bgolaszewski@baylibre.com>
Subject: [kmod][PATCH] module: fix error path in kmod_module_probe_insert_module()
Date: Sun, 26 May 2019 11:25:12 +0200	[thread overview]
Message-ID: <20190526092512.993-1-brgl@bgdev.pl> (raw)

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(-)

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)
-- 
2.21.0


             reply	other threads:[~2019-05-26  9:25 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-26  9:25 Bartosz Golaszewski [this message]
2019-05-28 22:21 ` [kmod][PATCH] module: fix error path in kmod_module_probe_insert_module() Lucas De Marchi

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=20190526092512.993-1-brgl@bgdev.pl \
    --to=brgl@bgdev.pl \
    --cc=bgolaszewski@baylibre.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-modules@vger.kernel.org \
    --cc=lucas.demarchi@intel.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).