The acp_max98388_hw_params() calls the snd_soc_card_get_codec_dai(), but does not check its return value which is a null pointer if the function fails. This can result in a null pointer dereference.
Add a null pointer check for snd_soc_card_get_codec_dai() to avoid null pointer dereference when the function fails.
Fixes: ac91c8c89782 ("ASoC: amd: acp: Add machine driver support for max98388 codec") Cc: stable@vger.kernel.org # v6.6 Signed-off-by: Wentao Liang vulab@iscas.ac.cn --- sound/soc/amd/acp/acp-mach-common.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/sound/soc/amd/acp/acp-mach-common.c b/sound/soc/amd/acp/acp-mach-common.c index f7602c1769bf..a795cc1836cc 100644 --- a/sound/soc/amd/acp/acp-mach-common.c +++ b/sound/soc/amd/acp/acp-mach-common.c @@ -918,6 +918,9 @@ static int acp_max98388_hw_params(struct snd_pcm_substream *substream, MAX98388_CODEC_DAI); int ret;
+ if (codec_dai) + return -EINVAL; + ret = snd_soc_dai_set_fmt(codec_dai, SND_SOC_DAIFMT_CBS_CFS | SND_SOC_DAIFMT_I2S | SND_SOC_DAIFMT_NB_NF);
linux-stable-mirror@lists.linaro.org