From: Luis Chamberlain <mcgrof@kernel.org>
To: Tiezhu Yang <yangtiezhu@loongson.cn>
Cc: Shuah Khan <shuah@kernel.org>,
linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
Xuefeng Li <lixuefeng@loongson.cn>
Subject: Re: [PATCH 3/4] kmod: Return directly if module name is empty in request_module()
Date: Sat, 18 Apr 2020 05:45:19 +0000 [thread overview]
Message-ID: <20200418054519.GX11244@42.do-not-panic.com> (raw)
In-Reply-To: <1587187200-13109-3-git-send-email-yangtiezhu@loongson.cn>
On Sat, Apr 18, 2020 at 01:19:59PM +0800, Tiezhu Yang wrote:
> If module name is empty, it is better to return directly at the beginning
> of request_module() without doing the needless call_modprobe() operation.
>
> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
> ---
> kernel/kmod.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/kernel/kmod.c b/kernel/kmod.c
> index 3cd075c..5851444 100644
> --- a/kernel/kmod.c
> +++ b/kernel/kmod.c
> @@ -28,6 +28,8 @@
>
> #include <trace/events/module.h>
>
> +#define MODULE_NOT_FOUND 256
> +
> /*
> * Assuming:
> *
> @@ -144,6 +146,9 @@ int __request_module(bool wait, const char *fmt, ...)
> if (ret >= MODULE_NAME_LEN)
> return -ENAMETOOLONG;
>
> + if (strlen(module_name) == 0)
> + return MODULE_NOT_FOUND;
I'd rather we just use something standard like -EINVAL.
What do we return if its not found? Then use that value.
> +
> ret = security_kernel_module_request(module_name);
> if (ret)
> return ret;
> --
> 2.1.0
>
next prev parent reply other threads:[~2020-04-18 5:45 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-18 5:19 [PATCH 1/4] selftests: kmod: Use variable NAME in kmod_test_0001() Tiezhu Yang
2020-04-18 5:19 ` [PATCH 2/4] kmod: Remove redundant "be an" in the comment Tiezhu Yang
2020-04-18 5:47 ` Luis Chamberlain
2020-04-18 5:19 ` [PATCH 3/4] kmod: Return directly if module name is empty in request_module() Tiezhu Yang
2020-04-18 5:45 ` Luis Chamberlain [this message]
2020-04-18 5:48 ` Luis Chamberlain
2020-04-18 5:58 ` Tiezhu Yang
2020-04-18 7:19 ` Luis Chamberlain
2020-04-20 4:08 ` Tiezhu Yang
2020-04-20 4:11 ` Tiezhu Yang
2020-04-18 5:20 ` [PATCH 4/4] test_kmod: Avoid potential double free in trigger_config_run_type() Tiezhu Yang
2020-04-18 5:47 ` Luis Chamberlain
2020-04-18 5:46 ` [PATCH 1/4] selftests: kmod: Use variable NAME in kmod_test_0001() Luis Chamberlain
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=20200418054519.GX11244@42.do-not-panic.com \
--to=mcgrof@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=lixuefeng@loongson.cn \
--cc=shuah@kernel.org \
--cc=yangtiezhu@loongson.cn \
/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