ASoC: tlv320aic31xx: Fix off by one error in the loop stucture.
authorJyri Sarha <jsarha@ti.com>
Mon, 24 Nov 2014 18:37:12 +0000 (20:37 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 16 Jan 2015 14:59:46 +0000 (06:59 -0800)
commit bbc686b34650b0f54affe9d9a637ccbe02b03760 upstream.

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

Reported-by: David Binderman <dcb314@hotmail.com>
Signed-off-by: Jyri Sarha <jsarha@ti.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
sound/soc/codecs/tlv320aic31xx.c

index 145fe5b253d40f3e4eb9b43db64bbd97e41f8775..93de5dd0a7b98f9413dcfefc4e13b80aee5c1a2c 100644 (file)
@@ -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 */