From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32836) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y9H0a-0005EO-Uo for qemu-devel@nongnu.org; Thu, 08 Jan 2015 12:36:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y9H09-00070A-Bi for qemu-devel@nongnu.org; Thu, 08 Jan 2015 12:36:32 -0500 Received: from e9.ny.us.ibm.com ([32.97.182.139]:46669) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y9H09-0006zq-7I for qemu-devel@nongnu.org; Thu, 08 Jan 2015 12:36:05 -0500 Received: from /spool/local by e9.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 8 Jan 2015 12:36:04 -0500 From: Michael Roth Date: Thu, 8 Jan 2015 11:34:29 -0600 Message-Id: <1420738472-23267-86-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1420738472-23267-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1420738472-23267-1-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 85/88] audio: Don't free hw resources until after hw backend is stopped List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org From: Peter Maydell 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 Signed-off-by: Peter Maydell Message-id: 1418406239-9838-1-git-send-email-peter.maydell@linaro.org (cherry picked from commit b28fb27b5edf77f6fd0ac550a156fb20f2218db3) Signed-off-by: Michael Roth --- audio/audio_template.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/audio/audio_template.h b/audio/audio_template.h index 8173188..584e536 100644 --- a/audio/audio_template.h +++ b/audio/audio_template.h @@ -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; } -- 1.9.1