From patchwork Tue Feb 24 21:47:54 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 44996 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 66DFF2029F for ; Tue, 24 Feb 2015 21:57:34 +0000 (UTC) Received: by mail-wi0-f198.google.com with SMTP id h11sf444235wiw.1 for ; Tue, 24 Feb 2015 13:57:33 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=Xjy2kfZhTovI8+lGmW+bdC91DB3zrjQHkarkY2PcWZw=; b=Jm1f2NQo74PnhgbQFRcGFdflHSp4aj9hMErnu+uyNfdtQ4vPi+KNB/r9HbpWOE498w g8cQpiI1Lcw7jlSTwFFjCx1fz8moXgJoQXK7PMrB8VZTwfsO+xSE4ypH5TcN7VGukiFe W2uJwfGNWZLP1GKA9OXHeRdS469p9KVbIWxGq0t3qnjAaIF0ci1GlzFh+dxtI0s/lnwL +h2NDk1jNC05aSXPczy0pJ6OHVGBoH00bb+ldJYXlPZa65EqRKXFAx/6k6XASpa0+FOI SlB8gOvVMAiJa2RyNjy46GA5a45mEyXCd4TcJvz/2/i31EnvSPA39u0vh7ccdP5OhbYu 9EEA== X-Gm-Message-State: ALoCoQnncjJvhjZQ/C2khqdTZu7EUpsm0GlaKhNVF8mitUNx5qiv7Wyms8ig1dCByraZY/XDJUel X-Received: by 10.152.29.97 with SMTP id j1mr10481lah.3.1424815053669; Tue, 24 Feb 2015 13:57:33 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.153.4.5 with SMTP id ca5ls670644lad.96.gmail; Tue, 24 Feb 2015 13:57:33 -0800 (PST) X-Received: by 10.112.54.228 with SMTP id m4mr100591lbp.20.1424815053486; Tue, 24 Feb 2015 13:57:33 -0800 (PST) Received: from mail-lb0-f181.google.com (mail-lb0-f181.google.com. [209.85.217.181]) by mx.google.com with ESMTPS id ug7si26519944lac.123.2015.02.24.13.57.33 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 24 Feb 2015 13:57:33 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.181 as permitted sender) client-ip=209.85.217.181; Received: by lbiw7 with SMTP id w7so28098040lbi.9 for ; Tue, 24 Feb 2015 13:57:33 -0800 (PST) X-Received: by 10.112.114.230 with SMTP id jj6mr24802lbb.112.1424815053362; Tue, 24 Feb 2015 13:57:33 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.35.133 with SMTP id h5csp2200451lbj; Tue, 24 Feb 2015 13:57:32 -0800 (PST) X-Received: by 10.140.23.134 with SMTP id 6mr115255qgp.84.1424815052082; Tue, 24 Feb 2015 13:57:32 -0800 (PST) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id i204si32187066qhc.58.2015.02.24.13.57.31 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 24 Feb 2015 13:57:32 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:51656 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQNTv-00067i-8I for patch@linaro.org; Tue, 24 Feb 2015 16:57:31 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47886) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQNO4-00031t-ON for qemu-devel@nongnu.org; Tue, 24 Feb 2015 16:51:33 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YQNNz-0006XJ-PY for qemu-devel@nongnu.org; Tue, 24 Feb 2015 16:51:28 -0500 Received: from e7.ny.us.ibm.com ([32.97.182.137]:51608) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YQNNz-0006XA-LI for qemu-devel@nongnu.org; Tue, 24 Feb 2015 16:51:23 -0500 Received: from /spool/local by e7.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 24 Feb 2015 16:51:23 -0500 Received: from d01dlp03.pok.ibm.com (9.56.250.168) by e7.ny.us.ibm.com (192.168.1.107) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 24 Feb 2015 16:51:21 -0500 Received: from b01cxnp23033.gho.pok.ibm.com (b01cxnp23033.gho.pok.ibm.com [9.57.198.28]) by d01dlp03.pok.ibm.com (Postfix) with ESMTP id F2879C90046; Tue, 24 Feb 2015 16:42:29 -0500 (EST) Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t1OLpJt529229148; Tue, 24 Feb 2015 21:51:19 GMT Received: from d01av04.pok.ibm.com (localhost [127.0.0.1]) by d01av04.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id t1OLpIxp030159; Tue, 24 Feb 2015 16:51:18 -0500 Received: from localhost (morrigu.austin.ibm.com [9.41.105.45]) by d01av04.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id t1OLpHpW030098; Tue, 24 Feb 2015 16:51:17 -0500 From: Michael Roth To: qemu-devel@nongnu.org Date: Tue, 24 Feb 2015 15:47:54 -0600 Message-Id: <1424814498-6993-20-git-send-email-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1424814498-6993-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1424814498-6993-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15022421-0037-0000-0000-000000B59360 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 32.97.182.137 Cc: Peter Maydell , qemu-stable@nongnu.org Subject: [Qemu-devel] [PATCH 19/43] audio: Don't free hw resources until after hw backend is stopped X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: mdroth@linux.vnet.ibm.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.181 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 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; }