From: Markus Armbruster <armbru@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: Peter Xu <peterx@redhat.com>,
qemu-devel@nongnu.org, Fabiano Rosas <farosas@suse.de>
Subject: Re: [PULL 4/9] migration: Use warn_reportf_err() where appropriate
Date: Tue, 25 Nov 2025 07:56:45 +0100 [thread overview]
Message-ID: <87ldjuk3bm.fsf@pond.sub.org> (raw)
In-Reply-To: <CAFEAcA9K8sFKSV+nbQ9UKJW5PNnnQwLNuuyQY7gX2LMEk8ui-g@mail.gmail.com> (Peter Maydell's message of "Mon, 24 Nov 2025 21:22:31 +0000")
Peter Maydell <peter.maydell@linaro.org> writes:
> On Sat, 22 Nov 2025 at 02:02, Peter Xu <peterx@redhat.com> wrote:
>>
>> From: Markus Armbruster <armbru@redhat.com>
>>
>> Replace
>>
>> warn_report("...: %s", ..., error_get_pretty(err));
>>
>> by
>>
>> warn_reportf_err(err, "...: ", ...);
>>
>> Prior art: commit 5217f1887a8 (error: Use error_reportf_err() where
>> appropriate).
>>
>> Signed-off-by: Markus Armbruster <armbru@redhat.com>
>> Reviewed-by: Fabiano Rosas <farosas@suse.de>
>> Link: https://lore.kernel.org/r/20251115083500.2753895-3-armbru@redhat.com
>> Signed-off-by: Peter Xu <peterx@redhat.com>
>> ---
>> migration/multifd.c | 4 ++--
>> 1 file changed, 2 insertions(+), 2 deletions(-)
>>
>> diff --git a/migration/multifd.c b/migration/multifd.c
>> index a529c399e4..6210454838 100644
>> --- a/migration/multifd.c
>> +++ b/migration/multifd.c
>> @@ -464,8 +464,8 @@ static void migration_ioc_shutdown_gracefully(QIOChannel *ioc)
>> */
>> migration_tls_channel_end(ioc, &local_err);
>> if (local_err) {
>> - warn_report("Failed to gracefully terminate TLS connection: %s",
>> - error_get_pretty(local_err));
>> + warn_reportf_err(local_err,
>> + "Failed to gracefully terminate TLS connection: ");
>> }
>> }
>
> Hi; Coverity points out (CID 1643463) that this introduces a double-free
> of local_err. In this function local_err is marked up as g_autoptr()
> so it is automatically freed when it goes out of scope. This was needed
> because error_get_pretty() doesn't free its argument. But
> warn_reportf_err() *does* free its error argument, so now we free it twice.
>
> Dropping the g_autoptr markup would be enough, I think.
I'll take care of it. Hand me the brown paper bag, please.
> The "prior art" commit 5217f1887a8 also seemed to introduce
> some double-frees in hw/usb/dev-mtp.c, but it looks like we
> fixed those in 562a55864 (but with a Fixes: tag that didn't
> point at the commit that introduced them but at a different
> blameless one).
You're right, it's the one that added the error_free(), which only
became wrong later.
I re-checked all of commit 5217f1887a8, and could not find lingering
double-frees.
Thanks!
next prev parent reply other threads:[~2025-11-25 6:57 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-22 0:26 [PULL 0/9] Staging patches Peter Xu
2025-11-22 0:26 ` [PULL 1/9] migration: Fix transition to COLO state from precopy Peter Xu
2025-11-22 0:26 ` [PULL 2/9] migration: set correct list pointer when removing notifier Peter Xu
2025-11-22 0:26 ` [PULL 3/9] migration: Plug memory leaks after migrate_set_error() Peter Xu
2025-11-22 0:26 ` [PULL 4/9] migration: Use warn_reportf_err() where appropriate Peter Xu
2025-11-24 21:22 ` Peter Maydell
2025-11-25 6:56 ` Markus Armbruster [this message]
2025-11-22 0:26 ` [PULL 5/9] migration/postcopy-ram: Improve error reporting after loadvm failure Peter Xu
2025-11-22 0:26 ` [PULL 6/9] tests/migration-test: Introduce MemType Peter Xu
2025-11-22 0:26 ` [PULL 7/9] tests/migration-test: Merge shmem_opts into memory_backend Peter Xu
2025-11-22 0:26 ` [PULL 8/9] tests/migration-test: Add MEM_TYPE_SHMEM Peter Xu
2025-11-22 0:26 ` [PULL 9/9] tests/migration-test: Use MEM_TYPE_MEMFD for memory_backend Peter Xu
2025-11-23 23:28 ` [PULL 0/9] Staging patches Richard Henderson
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=87ldjuk3bm.fsf@pond.sub.org \
--to=armbru@redhat.com \
--cc=farosas@suse.de \
--cc=peter.maydell@linaro.org \
--cc=peterx@redhat.com \
--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).