Skip to content

Commit b28fb27

Browse files
committed
audio: Don't free hw resources until after hw backend is stopped
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
1 parent 7e58e2a commit b28fb27

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

audio/audio_template.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,9 @@ static void glue (audio_pcm_hw_gc_, TYPE) (HW **hwp)
191191
audio_detach_capture (hw);
192192
#endif
193193
QLIST_REMOVE (hw, entries);
194+
glue (hw->pcm_ops->fini_, TYPE) (hw);
194195
glue (s->nb_hw_voices_, TYPE) += 1;
195196
glue (audio_pcm_hw_free_resources_ ,TYPE) (hw);
196-
glue (hw->pcm_ops->fini_, TYPE) (hw);
197197
g_free (hw);
198198
*hwp = NULL;
199199
}

0 commit comments

Comments
 (0)