Skip to content

Commit

Permalink
ASoC: Intel: Fix pcm stream context restore crash
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Mark Brown <broonie@linaro.org>
  • Loading branch information
Kevin Strasser authored and Mark Brown committed May 19, 2014
1 parent d7b54c3 commit 2fa190c
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sound/soc/intel/sst-baytrail-pcm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 2fa190c

Please sign in to comment.