From: Lakshmi Ramasubramanian Date: Wed, 21 Apr 2021 16:36:10 +0000 (-0700) Subject: powerpc: If kexec_build_elf_info() fails return immediately from elf64_load() X-Git-Tag: microblaze-v5.14~113^2 X-Git-Url: http://git.monstr.eu/?a=commitdiff_plain;h=031cc263c037a95e5d1249cbd3d55b77021f1eb8;p=linux-2.6-microblaze.git powerpc: If kexec_build_elf_info() fails return immediately from elf64_load() Uninitialized local variable "elf_info" would be passed to kexec_free_elf_info() if kexec_build_elf_info() returns an error in elf64_load(). If kexec_build_elf_info() returns an error, return the error immediately. Signed-off-by: Lakshmi Ramasubramanian Reported-by: Dan Carpenter Reviewed-by: Michael Ellerman Signed-off-by: Rob Herring Link: https://lore.kernel.org/r/20210421163610.23775-2-nramas@linux.microsoft.com --- diff --git a/arch/powerpc/kexec/elf_64.c b/arch/powerpc/kexec/elf_64.c index 02662e72c53d..eeb258002d1e 100644 --- a/arch/powerpc/kexec/elf_64.c +++ b/arch/powerpc/kexec/elf_64.c @@ -45,7 +45,7 @@ static void *elf64_load(struct kimage *image, char *kernel_buf, ret = kexec_build_elf_info(kernel_buf, kernel_len, &ehdr, &elf_info); if (ret) - goto out; + return ERR_PTR(ret); if (image->type == KEXEC_TYPE_CRASH) { /* min & max buffer values for kdump case */