From: Pingfan Liu <piliu@redhat.com>
To: kexec@lists.infradead.org
Cc: Jeremy Linton <jeremy.linton@arm.com>,
Pingfan Liu <piliu@redhat.com>,
horms@verge.net.au, ardb@kernel.org
Subject: [PATCHv2 2/6] arm64: Fix some issues with zImage _probe()
Date: Tue, 16 May 2023 15:31:20 +0800 [thread overview]
Message-ID: <20230516073124.23531-3-piliu@redhat.com> (raw)
In-Reply-To: <20230516073124.23531-1-piliu@redhat.com>
From: Jeremy Linton <jeremy.linton@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@arm.com>
Signed-off-by: Pingfan Liu <piliu@redhat.com>
To: kexec@lists.infradead.org
Cc: horms@verge.net.au
Cc: ardb@kernel.org
Cc: jeremy.linton@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
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
next prev parent reply other threads:[~2023-05-16 7:31 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-16 7:31 [PATCHv2 0/6] arm64: zboot support Pingfan Liu
2023-05-16 7:31 ` [PATCHv2 1/6] kexec: Change the image probe's prototype Pingfan Liu
2023-05-24 11:52 ` Simon Horman
2023-05-25 3:32 ` Pingfan Liu
2023-06-01 1:45 ` Pingfan Liu
2023-06-29 3:57 ` Pingfan Liu
2023-05-16 7:31 ` Pingfan Liu [this message]
2023-05-16 7:31 ` [PATCHv2 3/6] arm64: Scatter the logic of reading of kernel file into each probe Pingfan Liu
2023-05-16 7:31 ` [PATCHv2 4/6] kexec/zboot: Add arch independent zboot support Pingfan Liu
2023-05-16 7:31 ` [PATCHv2 5/6] arm64: Add ZBOOT PE containing compressed image support Pingfan Liu
2023-05-16 7:31 ` [PATCHv2 6/6] arm64: Hook up the ZBOOT support as vmlinuz Pingfan Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230516073124.23531-3-piliu@redhat.com \
--to=piliu@redhat.com \
--cc=ardb@kernel.org \
--cc=horms@verge.net.au \
--cc=jeremy.linton@arm.com \
--cc=kexec@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox