[bug report] ASoC: mediatek: mt8365: Add I2S DAI support

Dan Carpenter dan.carpenter at linaro.org
Wed Sep 11 00:33:43 PDT 2024


Hello Alexandre Mergnat,

Commit 402bbb13a195 ("ASoC: mediatek: mt8365: Add I2S DAI support")
from Jul 22, 2024 (linux-next), leads to the following Smatch static
checker warning:

	sound/soc/mediatek/mt8365/mt8365-dai-i2s.c:271 get_iir_coef()
	error: buffer overflow 'iir_coef_tbl_list' 8 <= 8

sound/soc/mediatek/mt8365/mt8365-dai-i2s.c
    259         const u32 *coef = NULL;
    260         unsigned int cnt = 0;
    261         u32 i = freq_new_index[input_fs];
    262         u32 j = freq_new_index[output_fs];
    263 
    264         if (i < 13 && j < 13) {
    265                 u32 k = iir_coef_tbl_matrix[i][j];
    266 
    267                 if (k >= IIR_NO_NEED) {
    268                 } else if (k == IIR_RATIOVER) {
    269                 } else if (k == IIR_INV_COEF) {

These if statements limit "k" to the 0-8 range.

    270                 } else {
--> 271                         coef = iir_coef_tbl_list[k].coef;
                                       ^^^^^^^^^^^^^^^^^^^^
But this array has 8 elements so it's off by one.

    272                         cnt = iir_coef_tbl_list[k].cnt;
    273                 }
    274         }
    275         *count = cnt;
    276         return coef;
    277 }

regards,
dan carpenter



More information about the Linux-mediatek mailing list