Commit 31d82c2c authored by Jia-Ju Bai's avatar Jia-Ju Bai Committed by Linus Torvalds

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: a43cac0d ("kexec: split kexec_file syscall code to kexec_file.c")
Signed-off-by: default avatarJia-Ju Bai <baijiaju1990@gmail.com>
Reported-by: default avatarTOTE Robot <oslab@tsinghua.edu.cn>
Acked-by: default avatarBaoquan He <bhe@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent a119b4e5
...@@ -740,8 +740,10 @@ static int kexec_calculate_store_digests(struct kimage *image) ...@@ -740,8 +740,10 @@ static int kexec_calculate_store_digests(struct kimage *image)
sha_region_sz = KEXEC_SEGMENT_MAX * sizeof(struct kexec_sha_region); sha_region_sz = KEXEC_SEGMENT_MAX * sizeof(struct kexec_sha_region);
sha_regions = vzalloc(sha_region_sz); sha_regions = vzalloc(sha_region_sz);
if (!sha_regions) if (!sha_regions) {
ret = -ENOMEM;
goto out_free_desc; goto out_free_desc;
}
desc->tfm = tfm; desc->tfm = tfm;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment