diff mbox series

[v2,2/2] powerpc: If kexec_build_elf_info() fails return immediately from elf64_load()

Message ID 20210421163610.23775-2-nramas@linux.microsoft.com
State Superseded
Headers show
Series None | expand

Commit Message

nramas April 21, 2021, 4:36 p.m. UTC
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 <nramas@linux.microsoft.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Reviewed-by: Michael Ellerman <mpe@ellerman.id.au>
---
 arch/powerpc/kexec/elf_64.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Rob Herring April 26, 2021, 9:26 p.m. UTC | #1
On Wed, 21 Apr 2021 09:36:10 -0700, Lakshmi Ramasubramanian wrote:
> 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 <nramas@linux.microsoft.com>

> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

> Reviewed-by: Michael Ellerman <mpe@ellerman.id.au>

> ---

>  arch/powerpc/kexec/elf_64.c | 2 +-

>  1 file changed, 1 insertion(+), 1 deletion(-)

> 


Applied, thanks!
diff mbox series

Patch

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 */