Skip to content

Commit

Permalink
proc: bootconfig: Add null pointer check
Browse files Browse the repository at this point in the history
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/[email protected]

Cc: [email protected]
Fixes: c1a3c36 ("proc: bootconfig: Add /proc/bootconfig to show boot config list")
Acked-by: Masami Hiramatsu <[email protected]>
Reported-by: Zeal Robot <[email protected]>
Signed-off-by: Lv Ruyi <[email protected]>
Signed-off-by: Steven Rostedt (Google) <[email protected]>
  • Loading branch information
Lv Ruyi authored and rostedt committed Apr 2, 2022
1 parent 8405541 commit bed5b60
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions fs/proc/bootconfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit bed5b60

Please sign in to comment.