From patchwork Thu Jan 8 17:34:29 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 42879 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f72.google.com (mail-wg0-f72.google.com [74.125.82.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 1F03126CD8 for ; Thu, 8 Jan 2015 18:18:24 +0000 (UTC) Received: by mail-wg0-f72.google.com with SMTP id a1sf2183850wgh.3 for ; Thu, 08 Jan 2015 10:18:23 -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=XGcGtQ/WUldA/UFwDQ6eM2Pj+vGIV/ek5H/l3unHetwGN9W7tOEHi3I7lbLFAeC6Fz E/NqXl6oQjFx63wyPcAnlE0XjPmZnVOGFatG9P9TmcGZSPRHNsKiIUDSEPbsckaU78P3 hQk2cIXLaTpHwyIx2NKShYCvoAQSWVZh6zEy04Uyj2DGaO7NJzvRMrXx0D2+ogJl3HXV JNQkwAlEd8+au8IddSTJdB00Mr58BMQUjoOr6em+SrpxJsgXQMp1OYcKK/58TkdHv4qD 5BNNTgq2amJxx2NWgCO+e5PWltd4RzM6CgV7iB/CLTS+zg+CqYpvKv3FT17gZWZR8tg1 yPEA== X-Gm-Message-State: ALoCoQnF9mUJsQxjEPtEKPnbuzTcNrTkA6N69onkqv9+eQ6CAR9Eo0Qm/hUS+pRwoabCR6rA09Ph X-Received: by 10.112.99.37 with SMTP id en5mr402525lbb.17.1420741103341; Thu, 08 Jan 2015 10:18:23 -0800 (PST) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.5.9 with SMTP id o9ls362204lao.83.gmail; Thu, 08 Jan 2015 10:18:23 -0800 (PST) X-Received: by 10.152.219.3 with SMTP id pk3mr16250037lac.19.1420741103166; Thu, 08 Jan 2015 10:18:23 -0800 (PST) Received: from mail-lb0-f175.google.com (mail-lb0-f175.google.com. [209.85.217.175]) by mx.google.com with ESMTPS id rd1si9898876lac.70.2015.01.08.10.18.23 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Thu, 08 Jan 2015 10:18:23 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.175 as permitted sender) client-ip=209.85.217.175; Received: by mail-lb0-f175.google.com with SMTP id z11so4322571lbi.6 for ; Thu, 08 Jan 2015 10:18:23 -0800 (PST) X-Received: by 10.112.180.135 with SMTP id do7mr16018992lbc.23.1420741103014; Thu, 08 Jan 2015 10:18:23 -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.9.200 with SMTP id c8csp80988lbb; Thu, 8 Jan 2015 10:18:22 -0800 (PST) X-Received: by 10.140.35.240 with SMTP id n103mr17144037qgn.11.1420741101160; Thu, 08 Jan 2015 10:18:21 -0800 (PST) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id b5si7901628qat.123.2015.01.08.10.18.20 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 08 Jan 2015 10:18:21 -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]:47528 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y9Hf2-0005ci-3t for patch@linaro.org; Thu, 08 Jan 2015 13:18:20 -0500 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 Received: from d01dlp01.pok.ibm.com (9.56.250.166) by e9.ny.us.ibm.com (192.168.1.109) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 8 Jan 2015 12:36:03 -0500 Received: from b01cxnp22036.gho.pok.ibm.com (b01cxnp22036.gho.pok.ibm.com [9.57.198.26]) by d01dlp01.pok.ibm.com (Postfix) with ESMTP id A19E138C8041; Thu, 8 Jan 2015 12:36:02 -0500 (EST) Received: from d01av04.pok.ibm.com (d01av04.pok.ibm.com [9.56.224.64]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id t08Ha2bg27328722; Thu, 8 Jan 2015 17:36:02 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 t08Ha2Rp003581; Thu, 8 Jan 2015 12:36:02 -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 t08Ha13A003512; Thu, 8 Jan 2015 12:36:01 -0500 From: Michael Roth To: qemu-devel@nongnu.org Date: Thu, 8 Jan 2015 11:34:29 -0600 Message-Id: <1420738472-23267-86-git-send-email-mdroth@linux.vnet.ibm.com> X-Mailer: git-send-email 1.9.1 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> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15010817-0033-0000-0000-00000180B703 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 32.97.182.139 Cc: qemu-stable@nongnu.org Subject: [Qemu-devel] [PATCH 85/88] 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.175 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; }