From patchwork Tue Sep 13 07:06:58 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bough Chen X-Patchwork-Id: 9328617 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 4E01660231 for ; Tue, 13 Sep 2016 09:37:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 413F828A4D for ; Tue, 13 Sep 2016 09:37:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 35E4F2925D; Tue, 13 Sep 2016 09:37:27 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7438E2921E for ; Tue, 13 Sep 2016 09:37:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757830AbcIMJhZ (ORCPT ); Tue, 13 Sep 2016 05:37:25 -0400 Received: from mail-db5eur01on0061.outbound.protection.outlook.com ([104.47.2.61]:17536 "EHLO EUR01-DB5-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1755679AbcIMJhZ (ORCPT ); Tue, 13 Sep 2016 05:37:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=tUILikIJ1+YBLTMj0p2XcYEM5CGozeGSssT+JrytkWc=; b=hpU9C8SvcXvOm5caxo33HFg6gml7mh+UssArl6xlpJgeLXWXc8ZIxYKSnpauPT6IWOcyg5BxfieIE2dxyTkzfiv/ydxL0MOeSFEx9suznSGtUKPU0Q0chqwlTkqHc8TmSJPn88gza4TO9BDWSuYpTcb2o+OtH8N3qXtfLFKg7A8= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=haibo.chen@nxp.com; Received: from b51421-server.ap.freescale.net (199.59.225.131) by HE1PR0401MB2329.eurprd04.prod.outlook.com (10.168.32.148) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA_P384) id 15.1.629.6; Tue, 13 Sep 2016 07:02:03 +0000 From: Haibo Chen To: , CC: Subject: [PATCH] mmc: sdhci: cast unsigned int to unsigned long long to avoid unexpeted error Date: Tue, 13 Sep 2016 15:06:58 +0800 Message-ID: <1473750418-23111-1-git-send-email-haibo.chen@nxp.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-Originating-IP: [199.59.225.131] X-ClientProxiedBy: SG2PR01CA0039.apcprd01.prod.exchangelabs.com (10.165.9.177) To HE1PR0401MB2329.eurprd04.prod.outlook.com (10.168.32.148) X-MS-Office365-Filtering-Correlation-Id: 3c1d3cd1-68b0-40c5-418d-08d3dba3df77 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:HE1PR0401MB2329; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046)(6055026); SRVR:HE1PR0401MB2329; BCL:0; PCL:0; RULEID:; SRVR:HE1PR0401MB2329; X-Forefront-PRVS: 0064B3273C X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(4630300001)(6009001)(7916002)(199003)(189002)(92566002)(5660300001)(105586002)(5003940100001)(68736007)(7736002)(106356001)(50986999)(5001770100001)(97736004)(81156014)(8676002)(101416001)(33646002)(42186005)(81166006)(7846002)(50226002)(4326007)(48376002)(47776003)(2906002)(305945005)(66066001)(229853001)(19580405001)(50466002)(15975445007)(189998001)(36756003)(19580395003)(3846002)(77096005)(6116002)(586003)(86362001)(7099028)(223183001); DIR:OUT; SFP:1101; SCL:1; SRVR:HE1PR0401MB2329; H:b51421-server.ap.freescale.net; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: nxp.com does not designate permitted sender hosts) X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Sep 2016 07:02:03.0410 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: HE1PR0401MB2329 Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Potentially overflowing expression 1000000 * data->timeout_clks with type unsigned int is evaluated using 32-bit arithmetic, and then used in a context that expects an expression of type unsigned long long. To avoid overflow, cast 1000000U to type unsigned long long. Special thanks to coverity Signed-off-by: Haibo Chen --- drivers/mmc/host/sdhci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c index 4805566..0e9f495 100644 --- a/drivers/mmc/host/sdhci.c +++ b/drivers/mmc/host/sdhci.c @@ -687,7 +687,7 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command *cmd) * host->clock is in Hz. target_timeout is in us. * Hence, us = 1000000 * cycles / Hz. Round up. */ - val = 1000000 * data->timeout_clks; + val = (unsigned long long)1000000 * data->timeout_clks; if (do_div(val, host->clock)) target_timeout++; target_timeout += val;