[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.LNX.2.00.1204122152340.7553@swampdragon.chaosbits.net>
Date: Thu, 12 Apr 2012 21:54:34 +0200 (CEST)
From: Jesper Juhl <jj@...osbits.net>
To: linux-kernel@...r.kernel.org
cc: alsa-devel@...a-project.org,
Vinod Koul <vinod.koul@...ux.intel.com>,
Lars-Peter Clausen <lars@...afoo.de>,
Brian Austin <brian.austin@...rus.com>,
Axel Lin <axel.lin@...il.com>, Takashi Iwai <tiwai@...e.de>,
Jaroslav Kysela <perex@...ex.cz>, Liam Girdwood <lrg@...com>,
Mark Brown <broonie@...nsource.wolfsonmicro.com>,
joe@...leusys.com, brian.austin@...rus.com
Subject: [PATCH] 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 <jj@...osbits.net>
---
sound/soc/codecs/cs42l73.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/sound/soc/codecs/cs42l73.c b/sound/soc/codecs/cs42l73.c
index 78979b3..07c44b7 100644
--- a/sound/soc/codecs/cs42l73.c
+++ b/sound/soc/codecs/cs42l73.c
@@ -929,6 +929,8 @@ static int cs42l73_set_mclk(struct snd_soc_dai *dai, unsigned int freq)
/* MCLKX -> MCLK */
mclkx_coeff = cs42l73_get_mclkx_coeff(freq);
+ if (mclkx_coeff < 0)
+ return mclkx_coeff;
mclk = cs42l73_mclkx_coeffs[mclkx_coeff].mclkx /
cs42l73_mclkx_coeffs[mclkx_coeff].ratio;
--
1.7.10
--
Jesper Juhl <jj@...osbits.net> http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists