From: Takashi Iwai Subject: Re: [PATCH 7/9] ASoC: ml26124: Fix negative array index read Date: Wed, 30 Oct 2013 18:40:04 +0100 Message-ID: References: <1383118507-21503-1-git-send-email-tiwai@suse.de> <1383118507-21503-8-git-send-email-tiwai@suse.de> <20131030164838.GH2493@sirena.org.uk> Mime-Version: 1.0 (generated by SEMI 1.14.6 - "Maruoka") Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Received: from mx2.suse.de (cantor2.suse.de [195.135.220.15]) by alsa0.perex.cz (Postfix) with ESMTP id 2FFA32617B6 for ; Wed, 30 Oct 2013 18:40:04 +0100 (CET) In-Reply-To: <20131030164838.GH2493@sirena.org.uk> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org To: Mark Brown Cc: alsa-devel@alsa-project.org, Liam Girdwood List-Id: alsa-devel@alsa-project.org At Wed, 30 Oct 2013 09:48:38 -0700, Mark Brown wrote: > > On Wed, Oct 30, 2013 at 08:35:05AM +0100, Takashi Iwai wrote: > > > int i = get_coeff(priv->mclk, params_rate(hw_params)); > > > > + if (i < 0) > > + return -EINVAL; > > This is ignoring the supplied error code, I'd expect to see the error > code being passed back (and fixed at the point where it's injected if > it's just returning -1 or something). Ah right. The revised patch is attached below. Takashi --- From: Takashi Iwai Subject: [PATCH v2] ASoC: ml26124: Fix negative array index read get_coeff() may return an error. Spotted by coverity CID 703394. Signed-off-by: Takashi Iwai --- sound/soc/codecs/ml26124.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sound/soc/codecs/ml26124.c b/sound/soc/codecs/ml26124.c index 26118828782b..185fa3bc3052 100644 --- a/sound/soc/codecs/ml26124.c +++ b/sound/soc/codecs/ml26124.c @@ -342,6 +342,8 @@ static int ml26124_hw_params(struct snd_pcm_substream *substream, struct ml26124_priv *priv = snd_soc_codec_get_drvdata(codec); int i = get_coeff(priv->mclk, params_rate(hw_params)); + if (i < 0) + return i; priv->substream = substream; priv->rate = params_rate(hw_params); -- 1.8.4.1