Received: by 10.223.176.5 with SMTP id f5csp876002wra; Tue, 6 Feb 2018 08:49:12 -0800 (PST) X-Google-Smtp-Source: AH8x224Qr3J3G0gWAeNCx9aakLX9hQ+emc1Ir0Rfn9bbvz+8oVvODN9NgUxMfEFy48oYqMd5G8kj X-Received: by 2002:a17:902:6849:: with SMTP id f9-v6mr3065375pln.113.1517935752137; Tue, 06 Feb 2018 08:49:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517935752; cv=none; d=google.com; s=arc-20160816; b=ThGxJdRwun/EI12+SvvCFEHTHkL/UFW7wGerMS/tWW7xBuI+eqjqtz2dunUVxNpC9g xPbWEJRNQdDsyJ5D0Df5t/tKQs832a2UsaAdwDt5XHjn5zGBt6V9/2nYc+ycb/lWAYkt HBdzPFzPiTQ33TAdBSwH2W76pZ3/0bNcbLxOZcQKBz0+3v49P8L5qfTFVD5yhUAlZXNV kpg4URkDmCQxxcfc8NhrFTVRLTqozjWJKpzji2R4dqMj9gwwFFh8dmrFmrF5PHbN5xpC HA+XutwGBGpjqpb/ZrLQX0Nqf5gzOnOe0hYBJSkFqFFz5VWSOcw4cM6pPWVl4LMDMHLu odLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=cSThPOXJxY9c0pkjGeukQIKx5n0aAj8oa76e1gEWqlI=; b=KExammbxZMAi9CF3i3AUwqV+wPM/lLWKX9THldyEQIChaI3UvevG4Yo6pS/5izlNsC 3n2TvnyDkG/5LKAq8hOhgepyD3T5fCqjWGPgCo8N+2FoQZh0xQ2biL1dbSo5YKJKdUYx UlqXIekAYDE/Q+RuByccfQubSkvBvLz0Vc35awG5Dix4z7rSwEHfO8skSYUXzx4jn9Xe dvVMMz2zb6Y/KyedSSEGhfrBFg4/sJM1gC9xEVKx9ZYEGfR+eRqWzwfemVSfU1rRoqb9 8gJs2Nr3bcaz8Urnm1eXrUHTNjtxsjnErlNZB+DZWGngn8V/1eF1T8ka0a+gcI6duoTT S4dA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f19-v6si8744211plr.641.2018.02.06.08.48.58; Tue, 06 Feb 2018 08:49:12 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752770AbeBFQrw (ORCPT + 99 others); Tue, 6 Feb 2018 11:47:52 -0500 Received: from gateway23.websitewelcome.com ([192.185.50.108]:27487 "EHLO gateway23.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752742AbeBFQrj (ORCPT ); Tue, 6 Feb 2018 11:47:39 -0500 Received: from cm14.websitewelcome.com (cm14.websitewelcome.com [100.42.49.7]) by gateway23.websitewelcome.com (Postfix) with ESMTP id 15AC7D815 for ; Tue, 6 Feb 2018 10:47:39 -0600 (CST) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id j6PCeGcz10aRHj6PDeb5KD; Tue, 06 Feb 2018 10:47:39 -0600 Received: from [189.175.4.238] (port=46642 helo=embeddedgus) by gator4166.hostgator.com with esmtpa (Exim 4.89_1) (envelope-from ) id 1ej6PC-000lD9-G1; Tue, 06 Feb 2018 10:47:38 -0600 Date: Tue, 6 Feb 2018 10:47:37 -0600 From: "Gustavo A. R. Silva" To: Ramesh Shanmugasundaram , Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH v3 3/8] i2c: max2175: use 64-bit arithmetic instead of 32-bit Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: 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 - vger.kernel.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.175.4.238 X-Source-L: No X-Exim-ID: 1ej6PC-000lD9-G1 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: (embeddedgus) [189.175.4.238]:46642 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 25 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add suffix LL to constant 2 in order to give the compiler complete information about the proper arithmetic to use. Notice that this constant is used in a context that expects an expression of type s64 (64 bits, signed). The expression 2 * (clock_rate - abs_nco_freq) is currently being evaluated using 32-bit arithmetic. Addresses-Coverity-ID: 1446589 ("Unintentional integer overflow") Signed-off-by: Gustavo A. R. Silva --- Changes in v2: - Update subject and changelog to better reflect the proposed code changes. - Add suffix LL to constant instead of casting a variable. Changes in v3: - Mention the specific Coverity report in the commit message. drivers/media/i2c/max2175.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/media/i2c/max2175.c b/drivers/media/i2c/max2175.c index 2f1966b..87cba15 100644 --- a/drivers/media/i2c/max2175.c +++ b/drivers/media/i2c/max2175.c @@ -643,7 +643,7 @@ static int max2175_set_nco_freq(struct max2175 *ctx, s32 nco_freq) if (abs_nco_freq < clock_rate / 2) { nco_val_desired = 2 * nco_freq; } else { - nco_val_desired = 2 * (clock_rate - abs_nco_freq); + nco_val_desired = 2LL * (clock_rate - abs_nco_freq); if (nco_freq < 0) nco_val_desired = -nco_val_desired; } -- 2.7.4