From patchwork Mon Aug 4 04:19:49 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nicolin Chen X-Patchwork-Id: 4666911 Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 3D763C0338 for ; Mon, 4 Aug 2014 04:19:19 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7557720200 for ; Mon, 4 Aug 2014 04:19:18 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 487B7201DD for ; Mon, 4 Aug 2014 04:19:17 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 186102625EF; Mon, 4 Aug 2014 06:19:16 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM, NO_DNS_FOR_FROM, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 9C410265382; Mon, 4 Aug 2014 06:18:22 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 699CB265457; Mon, 4 Aug 2014 06:18:21 +0200 (CEST) Received: from na01-by2-obe.outbound.protection.outlook.com (mail-by2lp0236.outbound.protection.outlook.com [207.46.163.236]) by alsa0.perex.cz (Postfix) with ESMTP id 68FFF2615F7 for ; Mon, 4 Aug 2014 06:17:35 +0200 (CEST) Received: from BY2PR03CA044.namprd03.prod.outlook.com (10.141.249.17) by BL2PR03MB353.namprd03.prod.outlook.com (10.141.89.16) with Microsoft SMTP Server (TLS) id 15.0.995.14; Mon, 4 Aug 2014 04:17:21 +0000 Received: from BL2FFO11FD046.protection.gbl (2a01:111:f400:7c09::120) by BY2PR03CA044.outlook.office365.com (2a01:111:e400:2c5d::17) with Microsoft SMTP Server (TLS) id 15.0.995.14 via Frontend Transport; Mon, 4 Aug 2014 04:17:21 +0000 Received: from az84smr01.freescale.net (192.88.158.2) by BL2FFO11FD046.mail.protection.outlook.com (10.173.161.208) with Microsoft SMTP Server (TLS) id 15.0.990.10 via Frontend Transport; Mon, 4 Aug 2014 04:17:20 +0000 Received: from rio.ap.freescale.net (rio.ap.freescale.net [10.192.242.9]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id s744HBgn026592; Sun, 3 Aug 2014 21:17:17 -0700 From: Nicolin Chen To: Date: Mon, 4 Aug 2014 12:19:49 +0800 Message-ID: <31ec001e493008c1d6e55f1d9d0787028112c4dc.1407125653.git.nicoleotsuka@gmail.com> X-Mailer: git-send-email 1.8.4 In-Reply-To: References: X-EOPAttributedMessage: 0 X-Matching-Connectors: 130515994409338463; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:CAL; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009002)(6009001)(199002)(189002)(87572001)(44976005)(73392001)(81342001)(73972005)(20776003)(33646002)(110136001)(19580395003)(80022001)(92726001)(19580405001)(50466002)(77156001)(88136002)(6806004)(77982001)(31966008)(89996001)(107046002)(64706001)(4396001)(46102001)(26826002)(93916002)(48376002)(104016003)(69596002)(2351001)(21056001)(99396002)(229853001)(79102001)(50226001)(47776003)(105596002)(104166001)(74502001)(55446002)(97736001)(83072002)(36756003)(92566001)(102836001)(106466001)(68736004)(81442001)(50986999)(74662001)(76176999)(86362001)(62966002)(85852003)(81542001)(61266001)(84676001)(82202001)(81156004)(95666004)(87286001)(85306004)(87936001); DIR:OUT; SFP:1101; SCL:1; SRVR:BL2PR03MB353; H:az84smr01.freescale.net; FPR:; MLV:ovrnspm; PTR:InfoDomainNonexistent; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID: X-Forefront-PRVS: 0293D40691 Received-SPF: SoftFail (protection.outlook.com: domain of transitioning gmail.com discourages use of 192.88.158.2 as permitted sender) Authentication-Results: spf=softfail (sender IP is 192.88.158.2) smtp.mailfrom=nicoleotsuka@gmail.com; Cc: alsa-devel@alsa-project.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, timur@tabi.org Subject: [alsa-devel] [PATCH 2/2] ASoC: fsl_asrc: Don't access members of config before checking it X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" 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 X-Virus-Scanned: ClamAV using ClamSMTP sound/soc/fsl/fsl_asrc.c:250 fsl_asrc_config_pair() warn: variable dereferenced before check 'config' (see line 243) git remote add next git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git git remote update next git checkout 3117bb3109dc223e186302f5dc8ce9ed04adca90 vim +/config +250 sound/soc/fsl/fsl_asrc.c 237 */ 238 static int fsl_asrc_config_pair(struct fsl_asrc_pair *pair) 239 { 240 struct asrc_config *config = pair->config; 241 struct fsl_asrc *asrc_priv = pair->asrc_priv; 242 enum asrc_pair_index index = pair->index; @243 u32 inrate = config->input_sample_rate, indiv; 244 u32 outrate = config->output_sample_rate, outdiv; 245 bool ideal = config->inclk == INCLK_NONE; 246 u32 clk_index[2], div[2]; 247 int in, out, channels; 248 struct clk *clk; 249 @250 if (!config) { 251 pair_err("invalid pair config\n"); 252 return -EINVAL; 253 } Reported-by: Dan Carpenter Signed-off-by: Nicolin Chen --- sound/soc/fsl/fsl_asrc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/sound/soc/fsl/fsl_asrc.c b/sound/soc/fsl/fsl_asrc.c index 06a96f3..86f45a1 100644 --- a/sound/soc/fsl/fsl_asrc.c +++ b/sound/soc/fsl/fsl_asrc.c @@ -240,12 +240,11 @@ static int fsl_asrc_config_pair(struct fsl_asrc_pair *pair) struct asrc_config *config = pair->config; struct fsl_asrc *asrc_priv = pair->asrc_priv; enum asrc_pair_index index = pair->index; - u32 inrate = config->input_sample_rate, indiv; - u32 outrate = config->output_sample_rate, outdiv; - bool ideal = config->inclk == INCLK_NONE; + u32 inrate, outrate, indiv, outdiv; u32 clk_index[2], div[2]; int in, out, channels; struct clk *clk; + bool ideal; if (!config) { pair_err("invalid pair config\n"); @@ -264,6 +263,10 @@ static int fsl_asrc_config_pair(struct fsl_asrc_pair *pair) return -EINVAL; } + inrate = config->input_sample_rate; + outrate = config->output_sample_rate; + ideal = config->inclk == INCLK_NONE; + /* Validate input and output sample rates */ for (in = 0; in < ARRAY_SIZE(supported_input_rate); in++) if (inrate == supported_input_rate[in])