All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ASoC: Intel: Fix pcm stream context restore crash
@ 2014-05-19  8:14 Jarkko Nikula
  2014-05-19 16:30 ` Mark Brown
  0 siblings, 1 reply; 2+ messages in thread
From: Jarkko Nikula @ 2014-05-19  8:14 UTC (permalink / raw
  To: alsa-devel; +Cc: Mark Brown, Jarkko Nikula, Liam Girdwood, Kevin Strasser

From: Kevin Strasser <kevin.strasser@intel.com>

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 <kevin.strasser@intel.com>
Signed-off-by: Jarkko Nikula <jarkko.nikula@linux.intel.com>
---
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) {
-- 
2.0.0.rc2

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] ASoC: Intel: Fix pcm stream context restore crash
  2014-05-19  8:14 [PATCH] ASoC: Intel: Fix pcm stream context restore crash Jarkko Nikula
@ 2014-05-19 16:30 ` Mark Brown
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Brown @ 2014-05-19 16:30 UTC (permalink / raw
  To: Jarkko Nikula; +Cc: alsa-devel, Liam Girdwood, Kevin Strasser


[-- Attachment #1.1: Type: text/plain, Size: 359 bytes --]

On Mon, May 19, 2014 at 11:14:23AM +0300, Jarkko Nikula wrote:
> From: Kevin Strasser <kevin.strasser@intel.com>
> 
> 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.

Applied, thanks.

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-05-19 16:30 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-19  8:14 [PATCH] ASoC: Intel: Fix pcm stream context restore crash Jarkko Nikula
2014-05-19 16:30 ` Mark Brown

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.