Skip to content

Commit 971784f

Browse files
Qais Yousefgregkh
authored andcommitted
ASoC: soc-compress.c: fix NULL dereference
commit d3268a4 upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 2605715 commit 971784f

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
@@ -666,7 +666,8 @@ int soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
666666
rtd->dai_link->stream_name);
667667

668668
ret = snd_pcm_new_internal(rtd->card->snd_card, new_name, num,
669-
1, 0, &be_pcm);
669+
rtd->dai_link->dpcm_playback,
670+
rtd->dai_link->dpcm_capture, &be_pcm);
670671
if (ret < 0) {
671672
dev_err(rtd->card->dev, "ASoC: can't create compressed for %s\n",
672673
rtd->dai_link->name);
@@ -675,8 +676,10 @@ int soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
675676

676677
rtd->pcm = be_pcm;
677678
rtd->fe_compr = 1;
678-
be_pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream->private_data = rtd;
679-
be_pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream->private_data = rtd;
679+
if (rtd->dai_link->dpcm_playback)
680+
be_pcm->streams[SNDRV_PCM_STREAM_PLAYBACK].substream->private_data = rtd;
681+
else if (rtd->dai_link->dpcm_capture)
682+
be_pcm->streams[SNDRV_PCM_STREAM_CAPTURE].substream->private_data = rtd;
680683
memcpy(compr->ops, &soc_compr_dyn_ops, sizeof(soc_compr_dyn_ops));
681684
} else
682685
memcpy(compr->ops, &soc_compr_ops, sizeof(soc_compr_ops));

0 commit comments

Comments
 (0)