From: Jesper Juhl <jj@chaosbits.net> To: linux-kernel@vger.kernel.org Cc: alsa-devel@alsa-project.org, Vinod Koul <vinod.koul@linux.intel.com>, Lars-Peter Clausen <lars@metafoo.de>, Brian Austin <brian.austin@cirrus.com>, Axel Lin <axel.lin@gmail.com>, Takashi Iwai <tiwai@suse.de>, Jaroslav Kysela <perex@perex.cz>, Liam Girdwood <lrg@ti.com>, Mark Brown <broonie@opensource.wolfsonmicro.com>, joe@nucleusys.com, brian.austin@cirrus.com Subject: [PATCH] ASoC: cs42l73: don't use negative array index Date: Thu, 12 Apr 2012 21:54:34 +0200 (CEST) [thread overview] Message-ID: <alpine.LNX.2.00.1204122152340.7553@swampdragon.chaosbits.net> (raw) 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@chaosbits.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@chaosbits.net> http://www.chaosbits.net/ Don't top-post http://www.catb.org/jargon/html/T/top-post.html Plain text mails only, please.
WARNING: multiple messages have this Message-ID (diff)
From: Jesper Juhl <jj@chaosbits.net> To: linux-kernel@vger.kernel.org Cc: brian.austin@cirrus.com, Lars-Peter Clausen <lars@metafoo.de>, Vinod Koul <vinod.koul@linux.intel.com>, joe@nucleusys.com, Takashi Iwai <tiwai@suse.de>, Mark Brown <broonie@opensource.wolfsonmicro.com>, alsa-devel@alsa-project.org, Axel Lin <axel.lin@gmail.com>, Liam Girdwood <lrg@ti.com> Subject: [PATCH] ASoC: cs42l73: don't use negative array index Date: Thu, 12 Apr 2012 21:54:34 +0200 (CEST) [thread overview] Message-ID: <alpine.LNX.2.00.1204122152340.7553@swampdragon.chaosbits.net> (raw) 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@chaosbits.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@chaosbits.net> http://www.chaosbits.net/ Don't top-post http://www.catb.org/jargon/html/T/top-post.html Plain text mails only, please.
next reply other threads:[~2012-04-12 19:54 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-04-12 19:54 Jesper Juhl [this message] 2012-04-12 19:54 ` [PATCH] ASoC: cs42l73: don't use negative array index Jesper Juhl 2012-04-13 9:02 ` Mark Brown 2012-04-13 9:02 ` Mark Brown
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=alpine.LNX.2.00.1204122152340.7553@swampdragon.chaosbits.net \ --to=jj@chaosbits.net \ --cc=alsa-devel@alsa-project.org \ --cc=axel.lin@gmail.com \ --cc=brian.austin@cirrus.com \ --cc=broonie@opensource.wolfsonmicro.com \ --cc=joe@nucleusys.com \ --cc=lars@metafoo.de \ --cc=linux-kernel@vger.kernel.org \ --cc=lrg@ti.com \ --cc=perex@perex.cz \ --cc=tiwai@suse.de \ --cc=vinod.koul@linux.intel.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.