Skip to contentSkip to conversation

ASoC: amd: acp: Add null pointer check in acp_max98388_hw_paramsi()

PATCH New Wentao Liang 1 participant 1 message May 14, 2025

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ASoC: amd: acp: Add null pointer check in acp_max98388_hw_paramsi()

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")
---
 sound/soc/amd/acp/acp-mach-common.c | 3 +++
 1 file changed, 3 insertions(+)
sound/soc/amd/acp/acp-mach-common.c +3 -0
index f7602c1769bf..a795cc1836cc 100644
@@ -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);
Signature · 1 line
2.42.0.windows.2