Skip to contentSkip to conversation

ASoC: tlv320aic31xx: Fix off by one error in the loop stucture.

PATCH Applied Jyri Sarha 2 participants 2 messages Nov 24, 2014

Subsystems (3)
lore
Share & tools
lore

Jyri Sarha

author
#0 lore raw

PATCH 1/1 ASoC: tlv320aic31xx: Fix off by one error in the loop stucture.

Fix off by one read beyond the end of a table.

---
 sound/soc/codecs/tlv320aic31xx.c |   13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)
sound/soc/codecs/tlv320aic31xx.c +7 -6
index 145fe5b..93de5dd 100644
@@ -911,12 +911,13 @@ static int aic31xx_set_dai_sysclk(struct snd_soc_dai *codec_dai,
 	}
 	aic31xx->p_div = i;
 
-	for (i = 0; aic31xx_divs[i].mclk_p != freq/aic31xx->p_div; i++) {
-		if (i == ARRAY_SIZE(aic31xx_divs)) {
-			dev_err(aic31xx->dev, "%s: Unsupported frequency %d\n",
-				__func__, freq);
-			return -EINVAL;
-		}
+	for (i = 0; i < ARRAY_SIZE(aic31xx_divs) &&
+		     aic31xx_divs[i].mclk_p != freq/aic31xx->p_div; i++)
+		;
+	if (i == ARRAY_SIZE(aic31xx_divs)) {
+		dev_err(aic31xx->dev, "%s: Unsupported frequency %d\n",
+			__func__, freq);
+		return -EINVAL;
 	}
 
 	/* set clock on MCLK, BCLK, or GPIO1 as PLL input */
Signature · 1 line
1.7.9.5
maintainer Applied
#1 lore raw
Quoted 1 line · Jyri Sarha

Fix off by one read beyond the end of a table.

Applied, thanks.