From: Jeremy Linton <[email protected]>

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 <[email protected]>
Signed-off-by: Pingfan Liu <[email protected]>
To: [email protected]
Cc: [email protected]
Cc: [email protected]
Cc: [email protected]
---
 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


_______________________________________________
kexec mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/kexec

Reply via email to