[PATCH v3 12/12] ASoC: mediatek: mt8189: Validate TDM MCLK frequency

From: phucduc . bui

Date: Wed Sep 16 2026 - 01:05:27 EST


From: bui duc phuc <phucduc.bui@xxxxxxxxx>

mtk_dai_tdm_cal_mclk() accepts zero or negative frequencies.
Reject invalid frequencies before configuring the TDM clock.

Fixes: 9f202872ba04 ("ASoC: mediatek: mt8189: support TDM in platform driver")
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@xxxxxxxxxxxxx>
Signed-off-by: bui duc phuc <phucduc.bui@xxxxxxxxx>
---

Changes in v3:
- Add Angelo's Reviewed-by tag.

sound/soc/mediatek/mt8189/mt8189-dai-tdm.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/sound/soc/mediatek/mt8189/mt8189-dai-tdm.c b/sound/soc/mediatek/mt8189/mt8189-dai-tdm.c
index 9aebd0320614..e113c52fe06a 100644
--- a/sound/soc/mediatek/mt8189/mt8189-dai-tdm.c
+++ b/sound/soc/mediatek/mt8189/mt8189-dai-tdm.c
@@ -383,6 +383,9 @@ static int mtk_dai_tdm_cal_mclk(struct mtk_base_afe *afe,
int apll;
int apll_rate;

+ if (freq <= 0)
+ return -EINVAL;
+
apll = mt8189_get_apll_by_rate(afe, freq);
apll_rate = mt8189_get_apll_rate(afe, apll);

--
2.43.0