From patchwork Fri Dec 12 17:43:59 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 42193 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f69.google.com (mail-wg0-f69.google.com [74.125.82.69]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 55B7426C99 for ; Fri, 12 Dec 2014 17:44:03 +0000 (UTC) Received: by mail-wg0-f69.google.com with SMTP id x12sf5201811wgg.0 for ; Fri, 12 Dec 2014 09:44:02 -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:cc:subject :date:message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=mtLp9MM2cmsqPKLXYAoZerVAQ4jPt7obFYV5/F/Q7fo=; b=K9auf0HId2hTYTL72nOtTILBuSTgkvLTu5blvlkuIn3H93tY+RbCS/NqzYtEfeW7p7 kgpCdJFARnM6/5ZxvozFWy+Kxj74cbZF/Skzq8g4azBS8H9Pfd1MOmg+tKjucwOiJBbo Zsl4prsSVegE2eOAhkF28jBbGA/xw3C0c3E/SFTnixuAktaDVKbST+xkiQyqTngCp22b Om/hPo1QZ0RDCBxDCtdZCn+2W8RvI8V8dRe+d5LEo0W9uerDIAcUz9lam9FxepdEfLIP TLZQZQuRxLHk63W+NyBnMqEo0U4vDZeZDV64F92Er73BmS+tDynxrbN2d5wsBtFtgOes 3xdg== X-Gm-Message-State: ALoCoQlgFrkOBrdMb4a2RFCveI0cZAiLjFIjpq3lhlrfisKm2+W/8iOlMyf+tQ8Zr7BgkPDvg8JR X-Received: by 10.194.95.74 with SMTP id di10mr2822153wjb.0.1418406242650; Fri, 12 Dec 2014 09:44:02 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.19.167 with SMTP id g7ls269178lae.62.gmail; Fri, 12 Dec 2014 09:44:02 -0800 (PST) X-Received: by 10.153.11.170 with SMTP id ej10mr16765857lad.24.1418406242392; Fri, 12 Dec 2014 09:44:02 -0800 (PST) Received: from mail-la0-f45.google.com (mail-la0-f45.google.com. [209.85.215.45]) by mx.google.com with ESMTPS id jh3si2140320lbc.5.2014.12.12.09.44.02 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 12 Dec 2014 09:44:02 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) client-ip=209.85.215.45; Received: by mail-la0-f45.google.com with SMTP id gq15so6583886lab.18 for ; Fri, 12 Dec 2014 09:44:02 -0800 (PST) X-Received: by 10.112.52.37 with SMTP id q5mr16482060lbo.32.1418406242263; Fri, 12 Dec 2014 09:44:02 -0800 (PST) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.112.142.69 with SMTP id ru5csp48135lbb; Fri, 12 Dec 2014 09:44:01 -0800 (PST) X-Received: by 10.180.221.72 with SMTP id qc8mr9819225wic.19.1418406241599; Fri, 12 Dec 2014 09:44:01 -0800 (PST) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [2001:8b0:1d0::1]) by mx.google.com with ESMTPS id da2si3801716wib.31.2014.12.12.09.44.01 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Fri, 12 Dec 2014 09:44:01 -0800 (PST) Received-SPF: none (google.com: pm215@archaic.org.uk does not designate permitted sender hosts) client-ip=2001:8b0:1d0::1; Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.80) (envelope-from ) id 1XzUFz-0002Z9-Li; Fri, 12 Dec 2014 17:43:59 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Cc: patches@linaro.org, Gerd Hoffmann Subject: [PATCH] audio: Don't free hw resources until after hw backend is stopped Date: Fri, 12 Dec 2014 17:43:59 +0000 Message-Id: <1418406239-9838-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.10.4 X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: peter.maydell@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.45 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 Signed-off-by: Peter Maydell --- 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; }