From: "Marc-André Lureau" <marcandre.lureau@redhat.com>
To: Akihiko Odaki <akihiko.odaki@daynix.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [PATCH] audio: Free consumed default audio devices
Date: Mon, 20 Nov 2023 10:32:41 +0400 [thread overview]
Message-ID: <CAMxuvayt2PHtZmFPWyMsXP5kLXYVT3Bhwowsk__8_Z_jTxvWjw@mail.gmail.com> (raw)
In-Reply-To: <20231119083940.20558-1-akihiko.odaki@daynix.com>
Hi
On Sun, Nov 19, 2023 at 12:40 PM Akihiko Odaki <akihiko.odaki@daynix.com> wrote:
>
> Failed default audio devices were removed from the list but not freed,
> and that made LeakSanitizer sad. Free default audio devices as they are
> consumed.
>
> Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
> ---
> audio/audio.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/audio/audio.c b/audio/audio.c
> index f91e05b72c..becf6cdf46 100644
> --- a/audio/audio.c
> +++ b/audio/audio.c
> @@ -1758,12 +1758,14 @@ static AudioState *audio_init(Audiodev *dev, Error **errp)
> goto out;
> }
> s->dev = dev = e->dev;
> + QSIMPLEQ_REMOVE_HEAD(&default_audiodevs, next);
> + g_free(e);
> drvname = AudiodevDriver_str(dev->driver);
> driver = audio_driver_lookup(drvname);
> if (!audio_driver_init(s, driver, dev, NULL)) {
> break;
> }
> - QSIMPLEQ_REMOVE_HEAD(&default_audiodevs, next);
> + qapi_free_Audiodev(dev);
I'd set s->dev to NULL, to avoid potential dangling pointers.
(it looks like like this could already hit a double-free on error path)
> }
> }
>
> --
> 2.42.1
>
prev parent reply other threads:[~2023-11-20 6:34 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-19 8:39 [PATCH] audio: Free consumed default audio devices Akihiko Odaki
2023-11-20 6:32 ` Marc-André Lureau [this message]
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=CAMxuvayt2PHtZmFPWyMsXP5kLXYVT3Bhwowsk__8_Z_jTxvWjw@mail.gmail.com \
--to=marcandre.lureau@redhat.com \
--cc=akihiko.odaki@daynix.com \
--cc=kraxel@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).