Skip to content

Commit d3268a4

Browse files
Qais Yousefbroonie
authored andcommitted
ASoC: soc-compress.c: fix NULL dereference
In soc_new_compress() when rtd->dai_link->dynamic is set, we create the pcm substreams with this call: ret = snd_pcm_new_internal(rtd->card->snd_card, new_name, num, 1, 0, &be_pcm); which passes 0 as capture_count leading to be_pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream being NULL, hence when trying to set rtd a few lines below we get an oops. Fix by using rtd->dai_link->dpcm_playback and rtd->dai_link->dpcm_capture as playback_count and capture_count to snd_pcm_new_internal(). Signed-off-by: Qais Yousef <qais.yousef@imgtec.com> Signed-off-by: Mark Brown <broonie@kernel.org> Cc: stable@vger.kernel.org
1 parent 97bf6af commit d3268a4

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

‎sound/soc/soc-compress.c‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -659,7 +659,8 @@ int soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
659659
rtd->dai_link->stream_name);
660660

661661
ret = snd_pcm_new_internal(rtd->card->snd_card, new_name, num,
662-
1, 0, &be_pcm);
662+
rtd->dai_link->dpcm_playback,
663+
rtd->dai_link->dpcm_capture, &be_pcm);
663664
if (ret < 0) {
664665
dev_err(rtd->card->dev, "ASoC: can't create compressed for %s\n",
665666
rtd->dai_link->name);
@@ -668,8 +669,10 @@ int soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
668669

669670
rtd->pcm = be_pcm;
670671
rtd->fe_compr = 1;
671-
be_pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream->private_data = rtd;
672-
be_pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream->private_data = rtd;
672+
if (rtd->dai_link->dpcm_playback)
673+
be_pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream->private_data = rtd;
674+
else if (rtd->dai_link->dpcm_capture)
675+
be_pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream->private_data = rtd;
673676
memcpy(compr->ops, &soc_compr_dyn_ops, sizeof(soc_compr_dyn_ops));
674677
} else
675678
memcpy(compr->ops, &soc_compr_ops, sizeof(soc_compr_ops));

0 commit comments

Comments
 (0)