]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
proc: bootconfig: Add null pointer check
authorLv Ruyi <lv.ruyi@zte.com.cn>
Tue, 29 Mar 2022 10:40:04 +0000 (10:40 +0000)
committerSteven Rostedt (Google) <rostedt@goodmis.org>
Sat, 2 Apr 2022 12:40:09 +0000 (08:40 -0400)
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

index 6d8d4bf2083773d097ec1fbbf1b1abe34721a731..2e244ada1f970b40dfc11417e5fd43579074d42f 100644 (file)
@@ -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);