]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ASoC: mediatek: mt8365: check validity before usage of i2s_data
authorMuhammad Usama Anjum <usama.anjum@collabora.com>
Wed, 11 Sep 2024 11:13:07 +0000 (16:13 +0500)
committerMark Brown <broonie@kernel.org>
Wed, 11 Sep 2024 12:59:33 +0000 (13:59 +0100)
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>
sound/soc/mediatek/mt8365/mt8365-dai-i2s.c

index 3482d8f8b4e77b49fac1004182e68b934e2755b9..11b9a5bc716382ec139a1da9382b563ac9d1e3e0 100644 (file)
@@ -465,13 +465,16 @@ void mt8365_afe_set_i2s_out_enable(struct mtk_base_afe *afe, bool enable)
        int i;
        unsigned long flags;
        struct mt8365_afe_private *afe_priv = afe->platform_priv;
-       struct mtk_afe_i2s_priv *i2s_data;
+       struct mtk_afe_i2s_priv *i2s_data = NULL;
 
        for (i = 0; i < DAI_I2S_NUM; i++) {
                if (mt8365_i2s_priv[i].adda_link)
                        i2s_data = afe_priv->dai_priv[mt8365_i2s_priv[i].id];
        }
 
+       if (!i2s_data)
+               return;
+
        spin_lock_irqsave(&afe_priv->afe_ctrl_lock, flags);
 
        if (enable) {