]> www.infradead.org Git - users/dwmw2/qemu.git/commitdiff
audio: Don't free hw resources until after hw backend is stopped
authorPeter Maydell <peter.maydell@linaro.org>
Tue, 16 Dec 2014 16:58:05 +0000 (16:58 +0000)
committerPeter Maydell <peter.maydell@linaro.org>
Mon, 22 Dec 2014 23:12:25 +0000 (23:12 +0000)
When stopping an audio voice, call the audio backend's fini
method before calling audio_pcm_hw_free_resources_ rather than
afterwards. This allows backends which use helper threads (like
pulseaudio) to terminate those threads before the conv_buf or
mix_buf are freed and avoids race conditions where the helper
may access a NULL pointer or freed memory.

Cc: qemu-stable@nongnu.org
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Message-id: 1418406239-9838-1-git-send-email-peter.maydell@linaro.org

audio/audio_template.h

index 817318853ccbcde0fe8b54d30875608c3657bfd8..584e536fac90d53fb753850b399ac0638fae05a7 100644 (file)
@@ -191,9 +191,9 @@ static void glue (audio_pcm_hw_gc_, TYPE) (HW **hwp)
         audio_detach_capture (hw);
 #endif
         QLIST_REMOVE (hw, entries);
+        glue (hw->pcm_ops->fini_, TYPE) (hw);
         glue (s->nb_hw_voices_, TYPE) += 1;
         glue (audio_pcm_hw_free_resources_ ,TYPE) (hw);
-        glue (hw->pcm_ops->fini_, TYPE) (hw);
         g_free (hw);
         *hwp = NULL;
     }