Skip to content

Commit ccb4214

Browse files
JiangJiasbroonie
authored andcommitted
ASoC: soc-compress: Change the check for codec_dai
It should be better to reverse the check on codec_dai and returned early in order to be easier to understand. Fixes: de2c6f9 ("ASoC: soc-compress: prevent the potentially use of null pointer") Reported-by: kernel test robot <lkp@intel.com> Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn> Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com> Link: https://lore.kernel.org/r/20220310030041.1556323-1-jiasheng@iscas.ac.cn Signed-off-by: Mark Brown <broonie@kernel.org>
1 parent 8fc2622 commit ccb4214

1 file changed

Lines changed: 11 additions & 8 deletions

File tree

sound/soc/soc-compress.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -567,16 +567,19 @@ int snd_soc_new_compress(struct snd_soc_pcm_runtime *rtd, int num)
567567
return -EINVAL;
568568
}
569569

570-
/* check client and interface hw capabilities */
571-
if (codec_dai) {
572-
if (snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_PLAYBACK) &&
573-
snd_soc_dai_stream_valid(cpu_dai, SNDRV_PCM_STREAM_PLAYBACK))
574-
playback = 1;
575-
if (snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_CAPTURE) &&
576-
snd_soc_dai_stream_valid(cpu_dai, SNDRV_PCM_STREAM_CAPTURE))
577-
capture = 1;
570+
if (!codec_dai) {
571+
dev_err(rtd->card->dev, "Missing codec\n");
572+
return -EINVAL;
578573
}
579574

575+
/* check client and interface hw capabilities */
576+
if (snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_PLAYBACK) &&
577+
snd_soc_dai_stream_valid(cpu_dai, SNDRV_PCM_STREAM_PLAYBACK))
578+
playback = 1;
579+
if (snd_soc_dai_stream_valid(codec_dai, SNDRV_PCM_STREAM_CAPTURE) &&
580+
snd_soc_dai_stream_valid(cpu_dai, SNDRV_PCM_STREAM_CAPTURE))
581+
capture = 1;
582+
580583
/*
581584
* Compress devices are unidirectional so only one of the directions
582585
* should be set, check for that (xor)

0 commit comments

Comments
 (0)