From: Shuah Khan <skhan@linuxfoundation.org>
To: agk@redhat.com, snitzer@redhat.com
Cc: Shuah Khan <skhan@linuxfoundation.org>,
dm-devel@redhat.com, linux-kernel@vger.kernel.org
Subject: [PATCH] dm: change dm_get_target_type() to check for module load error
Date: Mon, 4 Oct 2021 14:06:41 -0600 [thread overview]
Message-ID: <20211004200641.378496-1-skhan@linuxfoundation.org> (raw)
dm_get_target_type() doesn't check error return from request_module().
Change to check for error and return NULL instead of trying to get
target type again which would fail.
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>
---
drivers/md/dm-target.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/md/dm-target.c b/drivers/md/dm-target.c
index 64dd0b34fcf4..0789e9f91d3a 100644
--- a/drivers/md/dm-target.c
+++ b/drivers/md/dm-target.c
@@ -41,17 +41,22 @@ static struct target_type *get_target_type(const char *name)
return tt;
}
-static void load_module(const char *name)
+static int load_module(const char *name)
{
- request_module("dm-%s", name);
+ return request_module("dm-%s", name);
}
struct target_type *dm_get_target_type(const char *name)
{
struct target_type *tt = get_target_type(name);
+ int ret;
if (!tt) {
- load_module(name);
+ ret = load_module(name);
+ if (ret < 0) {
+ pr_err("Module %s load failed %d\n", name, ret);
+ return NULL;
+ }
tt = get_target_type(name);
}
--
2.30.2
next reply other threads:[~2021-10-04 20:06 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-04 20:06 Shuah Khan [this message]
2021-10-06 20:35 ` dm: change dm_get_target_type() to check for module load error Mike Snitzer
2021-10-06 20:55 ` Shuah Khan
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=20211004200641.378496-1-skhan@linuxfoundation.org \
--to=skhan@linuxfoundation.org \
--cc=agk@redhat.com \
--cc=dm-devel@redhat.com \
--cc=linux-kernel@vger.kernel.org \
--cc=snitzer@redhat.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