Skip to content

Commit 86fc499

Browse files
jjuhlbroonie
authored andcommitted
ASoC: cs42l73: don't use negative array index
If cs42l73_get_mclkx_coeff() returns < 0 (which it can) in sound/soc/codecs/cs42l73.c::cs42l73_set_mclk(), then we'll be using the (negative) return value as array index on the very next line of code - that's bad. Catch the negative return value and propagate it to the caller (which checks for it) and things are a bit more sane :-) Signed-off-by: Jesper Juhl <[email protected]> Signed-off-by: Mark Brown <[email protected]>
1 parent 7e1f7c8 commit 86fc499

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

sound/soc/codecs/cs42l73.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -929,6 +929,8 @@ static int cs42l73_set_mclk(struct snd_soc_dai *dai, unsigned int freq)
929929

930930
/* MCLKX -> MCLK */
931931
mclkx_coeff = cs42l73_get_mclkx_coeff(freq);
932+
if (mclkx_coeff < 0)
933+
return mclkx_coeff;
932934

933935
mclk = cs42l73_mclkx_coeffs[mclkx_coeff].mclkx /
934936
cs42l73_mclkx_coeffs[mclkx_coeff].ratio;

0 commit comments

Comments
 (0)