[PATCHv2 2/6] arm64: Fix some issues with zImage _probe()
Pingfan Liu
piliu at redhat.com
Tue May 16 00:31:20 PDT 2023
From: Jeremy Linton <jeremy.linton at arm.com>
Current compilers note that fname will be null while
attempting to print failures from strdup().
Further fix a memory leak caused by kernel_uncompressed_buf
never being used/freed before the allocated block is replaced
by the one returned by slurp_decompress_file().
Signed-off-by: Jeremy Linton <jeremy.linton at arm.com>
Signed-off-by: Pingfan Liu <piliu at redhat.com>
To: kexec at lists.infradead.org
Cc: horms at verge.net.au
Cc: ardb at kernel.org
Cc: jeremy.linton at arm.com
---
kexec/arch/arm64/kexec-zImage-arm64.c | 13 +------------
1 file changed, 1 insertion(+), 12 deletions(-)
diff --git a/kexec/arch/arm64/kexec-zImage-arm64.c b/kexec/arch/arm64/kexec-zImage-arm64.c
index c04669f..8a23dea 100644
--- a/kexec/arch/arm64/kexec-zImage-arm64.c
+++ b/kexec/arch/arm64/kexec-zImage-arm64.c
@@ -56,8 +56,7 @@ int zImage_arm64_probe(const char *kernel_buf, off_t kernel_size,
}
if (!(fname = strdup(FILENAME_IMAGE))) {
- dbgprintf("%s: Can't duplicate strings %s\n", __func__,
- fname);
+ dbgprintf("%s: Can't duplicate strings\n", __func__);
return -1;
}
@@ -68,15 +67,6 @@ int zImage_arm64_probe(const char *kernel_buf, off_t kernel_size,
goto fail_mkstemp;
}
- kernel_uncompressed_buf =
- (char *) calloc(kernel_size, sizeof(off_t));
- if (!kernel_uncompressed_buf) {
- dbgprintf("%s: Can't calloc %ld bytes\n",
- __func__, kernel_size);
- ret= -ENOMEM;
- goto fail_calloc;
- }
-
/* slurp in the input kernel */
dbgprintf("%s: ", __func__);
kernel_uncompressed_buf = slurp_decompress_file(kernel_buf,
@@ -129,7 +119,6 @@ int zImage_arm64_probe(const char *kernel_buf, off_t kernel_size,
fail_bad_header:
free(kernel_uncompressed_buf);
-fail_calloc:
if (fd >= 0)
close(fd);
--
2.31.1
More information about the kexec
mailing list