qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Peter Maydell <peter.maydell@linaro.org>
To: "Alex Bennée" <alex.bennee@linaro.org>
Cc: "Daan De Meyer" <daan.j.demeyer@gmail.com>,
	qemu-devel@nongnu.org, "Gerd Hoffmann" <kraxel@redhat.com>,
	"Philippe Mathieu-Daudé" <philmd@linaro.org>,
	qemu-arm@nongnu.org
Subject: Re: [PATCH] Add support for zboot images compressed with zstd
Date: Fri, 10 Oct 2025 13:09:35 +0100	[thread overview]
Message-ID: <CAFEAcA_hv0fMyJ7WQks8SA5Af7xVvTo3gjKNM4QBFCMWAH=2DA@mail.gmail.com> (raw)
In-Reply-To: <87sefrvuq5.fsf@draig.linaro.org>

On Fri, 10 Oct 2025 at 12:53, Alex Bennée <alex.bennee@linaro.org> wrote:
>
> Peter Maydell <peter.maydell@linaro.org> writes:
>
> > On Wed, 8 Oct 2025 at 20:17, Daan De Meyer <daan.j.demeyer@gmail.com> wrote:
> >> +    } else {
> >> +        fprintf(stderr,
> >> +                "unable to handle EFI zboot image with \"%.*s\" compression\n",
> >> +                (int)sizeof(header->compression_type) - 1,
> >> +                header->compression_type);
> >> +        return -1;
> >
> > Moving the "unrecognized compression type" error path down to
> > here means that we have moved it below the g_malloc() of the
> > data buffer, so we now need to g_free() to avoid a leak.
>
> Could we not declare:
>
>       g_autofree uint8_t *data = NULL;
>
> and drop the cleanup?

You could, if you wanted to, convert the file to g_autofree, yes.
You would need to also adjust the tail end of the function
in the success path to do
  *buffer = g_realloc(g_steal_pointer(&data), bytes);
so we don't double-free (and drop the cleanup in other
error exit paths).

I don't mind either way, but if we want to convert to g_autofree
we should do it as a preliminary patch.

-- PMM


  reply	other threads:[~2025-10-10 12:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-08 19:17 [PATCH] Add support for zboot images compressed with zstd Daan De Meyer
2025-10-10 10:05 ` Peter Maydell
2025-10-10 11:53   ` Alex Bennée
2025-10-10 12:09     ` Peter Maydell [this message]
2025-10-10 16:01       ` Peter Maydell

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='CAFEAcA_hv0fMyJ7WQks8SA5Af7xVvTo3gjKNM4QBFCMWAH=2DA@mail.gmail.com' \
    --to=peter.maydell@linaro.org \
    --cc=alex.bennee@linaro.org \
    --cc=daan.j.demeyer@gmail.com \
    --cc=kraxel@redhat.com \
    --cc=philmd@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).