Skip to content

Commit bed5b60

Browse files
Lv Ruyirostedt
authored andcommitted
proc: bootconfig: Add null pointer check
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: c1a3c36 ("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>
1 parent 8405541 commit bed5b60

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

fs/proc/bootconfig.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ static int __init copy_xbc_key_value_list(char *dst, size_t size)
3232
int ret = 0;
3333

3434
key = kzalloc(XBC_KEYLEN_MAX, GFP_KERNEL);
35+
if (!key)
36+
return -ENOMEM;
3537

3638
xbc_for_each_key_value(leaf, val) {
3739
ret = xbc_node_compose_key(leaf, key, XBC_KEYLEN_MAX);

0 commit comments

Comments
 (0)