From: Alistair Francis <alistair23@gmail.com>
To: philmd@linaro.org, alistair.francis@wdc.com,
vishalc@linux.ibm.com, qemu-devel@nongnu.org
Subject: Re: [PATCH 3/3] hw/core/loader: Free the allocated string from size_to_str()
Date: Fri, 31 Oct 2025 11:10:15 +1000 [thread overview]
Message-ID: <CAKmqyKPenVTBGfK4P5crzugGf_HVr_u38-g4Q4XOAt=g5VDdvw@mail.gmail.com> (raw)
In-Reply-To: <20251030015306.2279148-3-alistair.francis@wdc.com>
On Thu, Oct 30, 2025 at 11:53 AM <alistair23@gmail.com> wrote:
>
> From: Alistair Francis <alistair.francis@wdc.com>
>
> The string needs be be freed with g_free() according to the functions
> documentation.
>
> Coverity: CID 1642762
> Fixes: f62226f7dc44 ("hw/core/loader: improve error handling in image loading functions")
> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
Thanks!
Applied to riscv-to-apply.next
Alistair
> ---
> hw/core/loader.c | 6 +++++-
> 1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/hw/core/loader.c b/hw/core/loader.c
> index 1598dca03c..e83d245202 100644
> --- a/hw/core/loader.c
> +++ b/hw/core/loader.c
> @@ -153,8 +153,12 @@ ssize_t load_image_targphys_as(const char *filename,
> }
>
> if (size > max_sz) {
> + char *size_str = size_to_str(max_sz);
> +
> error_setg(errp, "%s exceeds maximum image size (%s)",
> - filename, size_to_str(max_sz));
> + filename, size_str);
> +
> + g_free(size_str);
> return -1;
> }
>
> --
> 2.51.0
>
next prev parent reply other threads:[~2025-10-31 1:13 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-30 1:53 [PATCH 1/3] hw/core/loader: Fixup whitespace for get_image_size() alistair23
2025-10-30 1:53 ` [PATCH 2/3] hw/core/loader: Free the image file descriptor on error alistair23
2025-10-30 8:24 ` Philippe Mathieu-Daudé
2025-10-30 8:27 ` Vishal Chourasia
2025-10-30 1:53 ` [PATCH 3/3] hw/core/loader: Free the allocated string from size_to_str() alistair23
2025-10-30 8:26 ` Philippe Mathieu-Daudé
2025-10-31 1:10 ` Alistair Francis [this message]
2025-10-30 8:23 ` [PATCH 1/3] hw/core/loader: Fixup whitespace for get_image_size() Vishal Chourasia
2025-10-30 8:26 ` Philippe Mathieu-Daudé
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='CAKmqyKPenVTBGfK4P5crzugGf_HVr_u38-g4Q4XOAt=g5VDdvw@mail.gmail.com' \
--to=alistair23@gmail.com \
--cc=alistair.francis@wdc.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=vishalc@linux.ibm.com \
/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;
as well as URLs for NNTP newsgroup(s).