diff mbox series

[50/91] kernel: kexec_file: fix error return code of kexec_calculate_store_digests()

Message ID 20210507010438.8fLVHEks0%akpm@linux-foundation.org (mailing list archive)
State New
Headers show
Series [01/91] alpha: eliminate old-style function definitions | expand

Commit Message

Andrew Morton May 7, 2021, 1:04 a.m. UTC
From: Jia-Ju Bai <baijiaju1990@gmail.com>
Subject: kernel: kexec_file: fix error return code of kexec_calculate_store_digests()

When vzalloc() returns NULL to sha_regions, no error return code of
kexec_calculate_store_digests() is assigned.  To fix this bug, ret is
assigned with -ENOMEM in this case.

Link: https://lkml.kernel.org/r/20210309083904.24321-1-baijiaju1990@gmail.com
Fixes: a43cac0d9dc2 ("kexec: split kexec_file syscall code to kexec_file.c")
Signed-off-by: Jia-Ju Bai <baijiaju1990@gmail.com>
Reported-by: TOTE Robot <oslab@tsinghua.edu.cn>
Acked-by: Baoquan He <bhe@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---

 kernel/kexec_file.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

--- a/kernel/kexec_file.c~kernel-kexec_file-fix-error-return-code-of-kexec_calculate_store_digests
+++ a/kernel/kexec_file.c
@@ -740,8 +740,10 @@  static int kexec_calculate_store_digests
 
 	sha_region_sz = KEXEC_SEGMENT_MAX * sizeof(struct kexec_sha_region);
 	sha_regions = vzalloc(sha_region_sz);
-	if (!sha_regions)
+	if (!sha_regions) {
+		ret = -ENOMEM;
 		goto out_free_desc;
+	}
 
 	desc->tfm   = tfm;