Skip to content

Commit

Permalink
kernel: kexec_file: fix error return code of kexec_calculate_store_di…
Browse files Browse the repository at this point in the history
…gests()

[ Upstream commit 31d82c2 ]

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: a43cac0 ("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>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
XidianGeneral authored and gregkh committed May 19, 2021
1 parent d43be02 commit 0886bb1
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion kernel/kexec_file.c
Expand Up @@ -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_regions = vzalloc(sha_region_sz);
if (!sha_regions)
if (!sha_regions) {
ret = -ENOMEM;
goto out_free_desc;
}

desc->tfm = tfm;

Expand Down

0 comments on commit 0886bb1

Please sign in to comment.