From patchwork Mon May 19 08:14:23 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jarkko Nikula X-Patchwork-Id: 4200131 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 5B5C2BEEAB for ; Mon, 19 May 2014 08:15:52 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 36F532020A for ; Mon, 19 May 2014 08:15:51 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 0D688201F5 for ; Mon, 19 May 2014 08:15:50 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id A5D9A2651A8; Mon, 19 May 2014 10:15:48 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 9D6202650B4; Mon, 19 May 2014 10:15:32 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 0A8242650B4; Mon, 19 May 2014 10:15:31 +0200 (CEST) Received: from mga03.intel.com (mga03.intel.com [143.182.124.21]) by alsa0.perex.cz (Postfix) with ESMTP id CBB2B265172 for ; Mon, 19 May 2014 10:15:08 +0200 (CEST) Received: from azsmga001.ch.intel.com ([10.2.17.19]) by azsmga101.ch.intel.com with ESMTP; 19 May 2014 01:15:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.98,865,1392192000"; d="scan'208";a="433848316" Received: from mylly.fi.intel.com (HELO mylly.fi.intel.com.) ([10.237.72.55]) by azsmga001.ch.intel.com with ESMTP; 19 May 2014 01:15:04 -0700 From: Jarkko Nikula To: alsa-devel@alsa-project.org Date: Mon, 19 May 2014 11:14:23 +0300 Message-Id: <1400487263-3951-1-git-send-email-jarkko.nikula@linux.intel.com> X-Mailer: git-send-email 2.0.0.rc2 Cc: Mark Brown , Jarkko Nikula , Liam Girdwood , Kevin Strasser Subject: [alsa-devel] [PATCH] ASoC: Intel: Fix pcm stream context restore crash X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP From: Kevin Strasser In some cases the pcm stream is closed while context has been scheduled to be restored, causing a null pointer deref panic. Cancel work to ensure stream does not get freed while work is still active/pending. Also, restoring the pcm context can be safely skipped after the stream has been stopped. Check if pcm stream is still running before restoring stream context to help pending work finish more quickly in stream close path. Signed-off-by: Kevin Strasser Signed-off-by: Jarkko Nikula --- For topic/intel branch since fixes issue in recently added suspend/resume code. --- sound/soc/intel/sst-baytrail-pcm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sound/soc/intel/sst-baytrail-pcm.c b/sound/soc/intel/sst-baytrail-pcm.c index 6242ccce2bb7..3af38576e91e 100644 --- a/sound/soc/intel/sst-baytrail-pcm.c +++ b/sound/soc/intel/sst-baytrail-pcm.c @@ -164,7 +164,8 @@ static void sst_byt_pcm_work(struct work_struct *work) struct sst_byt_pcm_data *pcm_data = container_of(work, struct sst_byt_pcm_data, work); - sst_byt_pcm_restore_stream_context(pcm_data->substream); + if (snd_pcm_running(pcm_data->substream)) + sst_byt_pcm_restore_stream_context(pcm_data->substream); } static int sst_byt_pcm_trigger(struct snd_pcm_substream *substream, int cmd) @@ -277,6 +278,7 @@ static int sst_byt_pcm_close(struct snd_pcm_substream *substream) dev_dbg(rtd->dev, "PCM: close\n"); + cancel_work_sync(&pcm_data->work); mutex_lock(&pcm_data->mutex); ret = sst_byt_stream_free(byt, pcm_data->stream); if (ret < 0) {