Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ASoC: mediatek: mt8365: check validity before usage of i2s_data

There may be a case where i2s_data may not get initialized by the for
loop which will cause the kernel crash. Initialize the i2s_data to NULL
and abort execute if it isn't found.

Fixes: 402bbb13a195 ("ASoC: mediatek: mt8365: Add I2S DAI support")
Signed-off-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
Link: https://patch.msgid.link/20240911111317.4072349-1-usama.anjum@collabora.com
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by

Muhammad Usama Anjum and committed by
Mark Brown
5c4e15e6 0b0aa67b

+4 -1
+4 -1
sound/soc/mediatek/mt8365/mt8365-dai-i2s.c
··· 465 465 int i; 466 466 unsigned long flags; 467 467 struct mt8365_afe_private *afe_priv = afe->platform_priv; 468 - struct mtk_afe_i2s_priv *i2s_data; 468 + struct mtk_afe_i2s_priv *i2s_data = NULL; 469 469 470 470 for (i = 0; i < DAI_I2S_NUM; i++) { 471 471 if (mt8365_i2s_priv[i].adda_link) 472 472 i2s_data = afe_priv->dai_priv[mt8365_i2s_priv[i].id]; 473 473 } 474 + 475 + if (!i2s_data) 476 + return; 474 477 475 478 spin_lock_irqsave(&afe_priv->afe_ctrl_lock, flags); 476 479