From patchwork Wed Jul 4 14:18:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gustavo A. R. Silva" X-Patchwork-Id: 10506965 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 5A4BA601D7 for ; Wed, 4 Jul 2018 14:19:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 47C7A28DA2 for ; Wed, 4 Jul 2018 14:19:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3C49D28E15; Wed, 4 Jul 2018 14:19:26 +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=-2.9 required=2.0 tests=BAYES_00, MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham 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 D6B1928DA2 for ; Wed, 4 Jul 2018 14:19:24 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 3801B267737; Wed, 4 Jul 2018 16:19:23 +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 DB27B267749; Wed, 4 Jul 2018 16:19:20 +0200 (CEST) Received: from gateway22.websitewelcome.com (gateway22.websitewelcome.com [192.185.47.109]) by alsa0.perex.cz (Postfix) with ESMTP id 53CCA26772D for ; Wed, 4 Jul 2018 16:19:17 +0200 (CEST) Received: from cm15.websitewelcome.com (cm15.websitewelcome.com [100.42.49.9]) by gateway22.websitewelcome.com (Postfix) with ESMTP id 8688C8FE9 for ; Wed, 4 Jul 2018 09:19:16 -0500 (CDT) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id aic7fpcfJbXuJaicVfzspI; Wed, 04 Jul 2018 09:19:15 -0500 X-Authority-Reason: nr=8 Received: from [189.250.65.56] (port=45880 helo=embeddedor) by gator4166.hostgator.com with esmtpa (Exim 4.91) (envelope-from ) id 1faic6-004Njh-RY; Wed, 04 Jul 2018 09:18:34 -0500 Date: Wed, 4 Jul 2018 09:18:33 -0500 From: "Gustavo A. R. Silva" To: Timur Tabi , Nicolin Chen , Xiubo Li , Fabio Estevam , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai Message-ID: <20180704141833.GA6702@embeddedor.com> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.24 (2015-08-30) X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - gator4166.hostgator.com X-AntiAbuse: Original Domain - alsa-project.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - embeddedor.com X-BWhitelist: no X-Source-IP: 189.250.65.56 X-Source-L: No X-Exim-ID: 1faic6-004Njh-RY X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: (embeddedor) [189.250.65.56]:45880 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 13 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes Cc: alsa-devel@alsa-project.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" Subject: [alsa-devel] [PATCH] ASoC: fsl_spdif: Use 64-bit arithmetic instead of 32-bit 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 Add suffix ULL to constant 64 in order to give the compiler complete information about the proper arithmetic to use. Notice that such constant is used in a context that expects an expression of type u64 (64 bits, unsigned) and the following expression is currently being evaluated using 32-bit arithmetic: rate[index] * txclk_df * 64 Addresses-Coverity-ID: 1222129 ("Unintentional integer overflow") Signed-off-by: Gustavo A. R. Silva Acked-by: Nicolin Chen --- sound/soc/fsl/fsl_spdif.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sound/soc/fsl/fsl_spdif.c b/sound/soc/fsl/fsl_spdif.c index 9b59d87..740b90d 100644 --- a/sound/soc/fsl/fsl_spdif.c +++ b/sound/soc/fsl/fsl_spdif.c @@ -1118,7 +1118,7 @@ static u32 fsl_spdif_txclk_caldiv(struct fsl_spdif_priv *spdif_priv, for (sysclk_df = sysclk_dfmin; sysclk_df <= sysclk_dfmax; sysclk_df++) { for (txclk_df = 1; txclk_df <= 128; txclk_df++) { - rate_ideal = rate[index] * txclk_df * 64; + rate_ideal = rate[index] * txclk_df * 64ULL; if (round) rate_actual = clk_round_rate(clk, rate_ideal); else