Received: by 10.223.176.5 with SMTP id f5csp3628962wra; Mon, 29 Jan 2018 16:32:32 -0800 (PST) X-Google-Smtp-Source: AH8x225415Lopm+oH0ZF/7c5zl2Juz8RdXyHo/kA+8XwUDWIwMrh4E2sPvNyqipgrwB6JkiC1/i4 X-Received: by 10.101.89.3 with SMTP id f3mr22537050pgu.372.1517272352395; Mon, 29 Jan 2018 16:32:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517272352; cv=none; d=google.com; s=arc-20160816; b=ULhkHQbNFNBLe6Y6ciMfCBoCWKeACk8IYt4dvAGP+zyBjiye4knzTXbVNVd6IfqzrH BYU2ufnUwgjsWfrCIbt9z2xHlhe18HVPvBJkE8HzEvfpujTW/O0hOeBF8tz3kL0p4SOT m1PHdHTnpVfbbQapOqSzaqb2VsNKXB/5f7pkPsrCsvnl7R6XltTYmTz62RlYzERuMfMg 4tQPlw3Ka6ZNhyk7sh+qqzBpeGP+1SaufUSTk9qPaSKTLFIDtYTFaUaLUEfSjU0Jzt4K ka8CbYjQcGd9KJytgglgR8YUtm5NUjKjB5cUjbxY2H97G3Nz8BRmWlfzkd5NQDXltdFU gmXw== 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=3XA5+K4E6RTmn4gWJ9uCwzl7LVoL8buKbOWdRglnMUU=; b=SPvQ15T7ZC9E2va2+grZaNrFvzI6VHPtPrC6OfpLR2W7PdiY3WRJVKuqbv3vGVWtOQ JTmtjdwDSBJaM+pKvt7SoiWwLLTm4r4Z+nFJsAMrRJ6aWHMUCt5QN87RarcgNrSgHjfo VMsnFxcW9qN8wBAfa66hYeJxPyjxrmBk6ASYqha32JjDPyykUNgXPP5RFoeQRpNKEGRM 0YRAMKhIfqkFIsfdFmzbD2ghpAee9FveJcWQJ+p7SkMgSykqh8hylRn7ylkbPHh+IUK9 X3fMUYlEFTmbtIn9hzZYKfSO9jmNaQaeZY0DB5aC0h5CPmMBMTKgpnaEgKK7r1ggusgo tpIA== 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 y96-v6si836236plh.454.2018.01.29.16.32.16; Mon, 29 Jan 2018 16:32:32 -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 S1752113AbeA3Abw (ORCPT + 99 others); Mon, 29 Jan 2018 19:31:52 -0500 Received: from gateway33.websitewelcome.com ([192.185.145.4]:15751 "EHLO gateway33.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751448AbeA3Abv (ORCPT ); Mon, 29 Jan 2018 19:31:51 -0500 Received: from cm16.websitewelcome.com (cm16.websitewelcome.com [100.42.49.19]) by gateway33.websitewelcome.com (Postfix) with ESMTP id 2D32440E93 for ; Mon, 29 Jan 2018 18:31:50 -0600 (CST) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id gJq2eO0xUODN4gJq2eJb0k; Mon, 29 Jan 2018 18:31:50 -0600 Received: from [189.145.57.174] (port=35454 helo=training) by gator4166.hostgator.com with esmtpa (Exim 4.89_1) (envelope-from ) id 1egJq1-001e8C-O5; Mon, 29 Jan 2018 18:31:49 -0600 Date: Mon, 29 Jan 2018 18:31:47 -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 3/8] i2c: max2175: fix potential integer overflow in max2175_set_nco_freq Message-ID: <4d475a610cb9c5c274ca4c9f4b1bc422c00776c0.1517268668.git.gustavo@embeddedor.com> 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.145.57.174 X-Source-L: No X-Exim-ID: 1egJq1-001e8C-O5 X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: (training) [189.145.57.174]:35454 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 21 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 Cast expression (clock_rate - abs_nco_freq) to s64 in order to avoid a potential integer overflow. This variable is being used in a context that expects an expression of type s64. Addresses-Coverity-ID: 1446589 ("Unintentional integer overflow") Signed-off-by: Gustavo A. R. Silva --- 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..3401ae6 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 = 2 * (s64)(clock_rate - abs_nco_freq); if (nco_freq < 0) nco_val_desired = -nco_val_desired; } -- 2.7.4