From patchwork Fri Dec 8 11:54:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Carpenter X-Patchwork-Id: 10102397 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 26854602A0 for ; Fri, 8 Dec 2017 11:54:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2616528AA8 for ; Fri, 8 Dec 2017 11:54:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1AB0128B96; Fri, 8 Dec 2017 11:54:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B6B1A28AA8 for ; Fri, 8 Dec 2017 11:54:56 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 9F4D1267BBF; Fri, 8 Dec 2017 12:54:54 +0100 (CET) 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 10A94267BC0; Fri, 8 Dec 2017 12:54:53 +0100 (CET) Received: from aserp2130.oracle.com (aserp2130.oracle.com [141.146.126.79]) by alsa0.perex.cz (Postfix) with ESMTP id 1983726698E for ; Fri, 8 Dec 2017 12:54:49 +0100 (CET) Received: from pps.filterd (aserp2130.oracle.com [127.0.0.1]) by aserp2130.oracle.com (8.16.0.21/8.16.0.21) with SMTP id vB8BpbmB185987; Fri, 8 Dec 2017 11:54:48 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=date : from : to : cc : subject : message-id : mime-version : content-type; s=corp-2017-10-26; bh=GdAmTId8tY3J5/bpDqG6qY60wbX+GIMZoGO4P/9N4ao=; b=ASTr3cs8YOurbIOyn2HzLV8ScC/8Ko5INwDAsKT83cQsWmzwHB4T4NvGNKQrNRgV0nsv tn7keSJUrWoBiA9tn0IRwpIjMfhqq8oze7rE2blSwnGBeFfVE1ysJ7ZUfjF7QK8ItrXz f7Y89vu5F3XF6fnA9Xb9u9hjtJMQfs8SZJqTAt55ZnVeZl8DMqPQoZ+h59MPgWdTLyyY V5n54FmgWMobAjc0bEPDpZ8Yqk9fYrKeRCF/zTY2P+CRXRSvhBfDNC2IW498G9JP/uNC WeVKCG8gf/9Tz0N5rw9/uzvudk1UMCyom8ySAZKGbsiRLsXgl9ht19mJzVEDp3z4cRJH UA== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp2130.oracle.com with ESMTP id 2eqt76r0fh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 08 Dec 2017 11:54:48 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id vB8Bsjak021110 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 8 Dec 2017 11:54:45 GMT Received: from abhmp0005.oracle.com (abhmp0005.oracle.com [141.146.116.11]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id vB8Bsinl013108; Fri, 8 Dec 2017 11:54:45 GMT Received: from mwanda (/197.157.0.59) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Fri, 08 Dec 2017 03:54:43 -0800 Date: Fri, 8 Dec 2017 14:54:25 +0300 From: Dan Carpenter To: Liam Girdwood , Sriram Periyasamy Message-ID: <20171208115425.rqclgmhcph5gn47j@mwanda> MIME-Version: 1.0 Content-Disposition: inline X-Mailer: git-send-email haha only kidding User-Agent: NeoMutt/20170609 (1.8.3) X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8738 signatures=668644 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1711220000 definitions=main-1712080171 Cc: alsa-devel@alsa-project.org, Jani Nikula , Pankaj Bharadiya , Guneshwor Singh , Takashi Iwai , Vinod Koul , kernel-janitors@vger.kernel.org, Mark Brown , Senthilnathan Veppur , Andy Shevchenko , "Subhransu S. Prusty" Subject: [alsa-devel] [PATCH] ASoC: Intel: Skylake: Re-order some code to silence a warning 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 I get a Smatch warning here: sound/soc/intel/skylake/skl-nhlt.c:335 skl_get_ssp_clks() error: testing array offset 'j' after use. The code is harmless, but the checker is right that we should swap these two conditions so we verify that the offset is within bounds before we use it. Signed-off-by: Dan Carpenter Reviewed-by: Sriram Periyasamy Acked-By: Vinod Koul diff --git a/sound/soc/intel/skylake/skl-nhlt.c b/sound/soc/intel/skylake/skl-nhlt.c index afa557a1c031..54f9bd630f4f 100644 --- a/sound/soc/intel/skylake/skl-nhlt.c +++ b/sound/soc/intel/skylake/skl-nhlt.c @@ -331,8 +331,8 @@ static void skl_get_ssp_clks(struct skl *skl, struct skl_ssp_clk *ssp_clks, rate = channels * bps * fs; /* check if the rate is added already to the given SSP's sclk */ - for (j = 0; (sclk[id].rate_cfg[j].rate != 0) && - (j < SKL_MAX_CLK_RATES); j++) { + for (j = 0; (j < SKL_MAX_CLK_RATES) && + (sclk[id].rate_cfg[j].rate != 0); j++) { if (sclk[id].rate_cfg[j].rate == rate) { present = true; break;