From: Masami Hiramatsu <mhiramat@kernel.org>
To: cgel.zte@gmail.com
Cc: linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org,
Lv Ruyi <lv.ruyi@zte.com.cn>, Zeal Robot <zealci@zte.com.cn>
Subject: Re: [PATCH] proc: bootconfig: add null pointer check
Date: Tue, 29 Mar 2022 23:21:37 +0900 [thread overview]
Message-ID: <20220329232137.c63ea3258df2176667d6f846@kernel.org> (raw)
In-Reply-To: <20220329104004.2376879-1-lv.ruyi@zte.com.cn>
On Tue, 29 Mar 2022 10:40:04 +0000
cgel.zte@gmail.com wrote:
> From: Lv Ruyi <lv.ruyi@zte.com.cn>
>
> kzalloc is a memory allocation function which can return NULL when some
> internal memory errors happen. It is safer to add null pointer check.
Oops, yes.
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Thank you!
>
> Reported-by: Zeal Robot <zealci@zte.com.cn>
> Signed-off-by: Lv Ruyi <lv.ruyi@zte.com.cn>
> ---
> fs/proc/bootconfig.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/fs/proc/bootconfig.c b/fs/proc/bootconfig.c
> index 6d8d4bf20837..2e244ada1f97 100644
> --- a/fs/proc/bootconfig.c
> +++ b/fs/proc/bootconfig.c
> @@ -32,6 +32,8 @@ static int __init copy_xbc_key_value_list(char *dst, size_t size)
> int ret = 0;
>
> key = kzalloc(XBC_KEYLEN_MAX, GFP_KERNEL);
> + if (!key)
> + return -ENOMEM;
>
> xbc_for_each_key_value(leaf, val) {
> ret = xbc_node_compose_key(leaf, key, XBC_KEYLEN_MAX);
> --
> 2.25.1
>
--
Masami Hiramatsu <mhiramat@kernel.org>
next prev parent reply other threads:[~2022-03-29 14:21 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-29 10:40 [PATCH] proc: bootconfig: add null pointer check cgel.zte
2022-03-29 14:21 ` Masami Hiramatsu [this message]
2022-03-29 14:30 ` Masami Hiramatsu
2022-03-29 14:46 ` Steven Rostedt
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=20220329232137.c63ea3258df2176667d6f846@kernel.org \
--to=mhiramat@kernel.org \
--cc=cgel.zte@gmail.com \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lv.ruyi@zte.com.cn \
--cc=zealci@zte.com.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;
as well as URLs for NNTP newsgroup(s).