public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: linux-kernel@vger.kernel.org
Cc: Ingo Molnar <mingo@kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	stable@vger.kernel.org, Masami Hiramatsu <mhiramat@kernel.org>,
	Zeal Robot <zealci@zte.com.cn>, Lv Ruyi <lv.ruyi@zte.com.cn>
Subject: [for-linus][PATCH 2/7] proc: bootconfig: Add null pointer check
Date: Sun, 03 Apr 2022 10:25:02 -0400	[thread overview]
Message-ID: <20220403143139.633512320@goodmis.org> (raw)
In-Reply-To: 20220403142500.388473000@goodmis.org

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.

Link: https://lkml.kernel.org/r/20220329104004.2376879-1-lv.ruyi@zte.com.cn

Cc: stable@vger.kernel.org
Fixes: c1a3c36017d4 ("proc: bootconfig: Add /proc/bootconfig to show boot config list")
Acked-by: Masami Hiramatsu <mhiramat@kernel.org>
Reported-by: Zeal Robot <zealci@zte.com.cn>
Signed-off-by: Lv Ruyi <lv.ruyi@zte.com.cn>
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 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.35.1

  parent reply	other threads:[~2022-04-03 14:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-03 14:25 [for-linus][PATCH 0/7] tracing: Updates to the last pull request for 5.18 Steven Rostedt
2022-04-03 14:25 ` [for-linus][PATCH 1/7] tracing: Rename the staging files for trace_events Steven Rostedt
2022-04-03 14:25 ` Steven Rostedt [this message]
2022-04-03 14:25 ` [for-linus][PATCH 3/7] tracing/user_events: Hold event_mutex during dyn_event_add Steven Rostedt
2022-04-03 14:25 ` [for-linus][PATCH 4/7] tracing/user_events: Remove eBPF interfaces Steven Rostedt
2022-04-03 14:25 ` [for-linus][PATCH 5/7] tracing: Set user_events to BROKEN Steven Rostedt
2022-04-03 14:25 ` [for-linus][PATCH 6/7] ftrace: Make ftrace_graph_is_dead() a static branch Steven Rostedt
2022-04-03 14:25 ` [for-linus][PATCH 7/7] tracing: Move user_events.h temporarily out of include/uapi 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=20220403143139.633512320@goodmis.org \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lv.ruyi@zte.com.cn \
    --cc=mhiramat@kernel.org \
    --cc=mingo@kernel.org \
    --cc=stable@vger.kernel.org \
    --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