Received: by 10.223.176.5 with SMTP id f5csp4036904wra; Tue, 30 Jan 2018 00:52:43 -0800 (PST) X-Google-Smtp-Source: AH8x226PfeG4oqq/qAwWS2HRcHO0yHn1qQDmkWanWWLbMT1m36gNhQsLrSiNdmgdUFxYwzvMqqwO X-Received: by 10.101.76.75 with SMTP id l11mr23051613pgr.224.1517302363393; Tue, 30 Jan 2018 00:52:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517302363; cv=none; d=google.com; s=arc-20160816; b=TKTJq4jvN8H9kztb+teoQlirzYfDXC8X0DWReowd9UEwG0A5e7swkDQCdVfL4eYV58 rysX+l15XDmkqBkB13vM2nUu5YEKgpzsvMPqlPr2iAOffBozpIFxSE7G2fkIHOIHHkvc LocBJILISrhoXLTkdXevWuvQQ/SVSk1fqNODtv3/A/ZPg+mcD2M+x3I14yqduAp6RHST ESFbaMZpu9/24HP9ARV0uPtUe84+CIETrHmItiUqFdTOZqg9z1ddU5SunAzW1gKBO2fE yPUYdIIcrQ1QboON7b6zXbbKeKEUhceauMYZArCzsm1qcF3b6Y8P3zP+usdc9nQMfO/h bj1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-disposition:mime-version :user-agent:in-reply-to:references:subject:cc:to:from:message-id :date:arc-authentication-results; bh=vOJBjzCk1WrXY6tzFvA8Viw4lb/1zYFaWDoQZKZgRL8=; b=fGejY4HOCK7vuelROMqkQO+T3jiZfrU8C9zhtYSPWfvNAx1nTIXQkFj8ERxqF+2Ilc ARC43gXyQezA64i/Oa6WQ0gGMEctTxO2iW+ybi4E9QtrvSavoG84VYuhSvSFhpbD8yk3 IFIXuSI4xn0mj+iq7Y6/rpfkj+2nVSwjzZvkbDhd/3K2kAejSrVjvPMr/bZuYCYhh95M KZ0poEf87kecHBnhnfWObo1OONr7/QA8iQ+7mTBMT7HAV0Hjp1S0ckyenT0/Aqg91JgS Znhunoo4JID9v2wWb/eO1U6oo8+5Emd7Xlaa8KNPES6nvG3Q0RftMAZ7V5OGFcihkAhW BUTg== 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 l70si13888180pfa.176.2018.01.30.00.52.29; Tue, 30 Jan 2018 00:52:43 -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 S1751828AbeA3Ivo (ORCPT + 99 others); Tue, 30 Jan 2018 03:51:44 -0500 Received: from gateway24.websitewelcome.com ([192.185.51.253]:28769 "EHLO gateway24.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751496AbeA3Ivn (ORCPT ); Tue, 30 Jan 2018 03:51:43 -0500 Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway24.websitewelcome.com (Postfix) with ESMTP id 89CC72B9C9 for ; Tue, 30 Jan 2018 02:51:42 -0600 (CST) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id gRdmeENrRBUMKgRdmeIyY5; Tue, 30 Jan 2018 02:51:42 -0600 Received: from gator4166.hostgator.com ([108.167.133.22]:51843) by gator4166.hostgator.com with esmtpsa (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.89_1) (envelope-from ) id 1egRdm-000PJ9-7H; Tue, 30 Jan 2018 02:51:42 -0600 Received: from 189.152.201.65 ([189.152.201.65]) by gator4166.hostgator.com (Horde Framework) with HTTPS; Tue, 30 Jan 2018 02:51:41 -0600 Date: Tue, 30 Jan 2018 02:51:41 -0600 Message-ID: <20180130025141.Horde.h4aoQSwrqdPlpFtSKtB9DuS@gator4166.hostgator.com> From: "Gustavo A. R. Silva" To: Hans Verkuil Cc: "Gustavo A. R. Silva" , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 8/8] platform: vivid-cec: fix potential integer overflow in vivid_cec_pin_adap_events References: <00eea53890802b679c138fc7f68a0f162261d95c.1517268668.git.gustavo@embeddedor.com> <2e1afa55-d214-f932-4ba7-2e21f6a2cd3d@xs4all.nl> In-Reply-To: <2e1afa55-d214-f932-4ba7-2e21f6a2cd3d@xs4all.nl> User-Agent: Horde Application Framework 5 Content-Type: text/plain; charset=utf-8; format=flowed; DelSp=Yes MIME-Version: 1.0 Content-Disposition: inline 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: 108.167.133.22 X-Source-L: Yes X-Exim-ID: 1egRdm-000PJ9-7H X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: gator4166.hostgator.com [108.167.133.22]:51843 X-Source-Auth: garsilva@embeddedor.com X-Email-Count: 1 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 Hi Hans, Quoting Hans Verkuil : > Hi Gustavo, > > On 01/30/2018 01:33 AM, Gustavo A. R. Silva wrote: >> Cast len to const u64 in order to avoid a potential integer >> overflow. This variable is being used in a context that expects >> an expression of type const u64. >> >> Addresses-Coverity-ID: 1454996 ("Unintentional integer overflow") >> Signed-off-by: Gustavo A. R. Silva >> --- >> drivers/media/platform/vivid/vivid-cec.c | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/drivers/media/platform/vivid/vivid-cec.c >> b/drivers/media/platform/vivid/vivid-cec.c >> index b55d278..30240ab 100644 >> --- a/drivers/media/platform/vivid/vivid-cec.c >> +++ b/drivers/media/platform/vivid/vivid-cec.c >> @@ -83,7 +83,7 @@ static void vivid_cec_pin_adap_events(struct >> cec_adapter *adap, ktime_t ts, >> if (adap == NULL) >> return; >> ts = ktime_sub_us(ts, (CEC_TIM_START_BIT_TOTAL + >> - len * 10 * CEC_TIM_DATA_BIT_TOTAL)); >> + (const u64)len * 10 * CEC_TIM_DATA_BIT_TOTAL)); > > This makes no sense. Certainly the const part is pointless. And given that > len is always <= 16 there definitely is no overflow. > Yeah, I understand your point and I know there is no chance of an overflow in this particular case. > I don't really want this cast in the code. > > Sorry, > I'm working through all the Linux kernel Coverity reports, and I thought of sending a patch for this because IMHO it doesn't hurt to give the compiler complete information about the arithmetic in which an expression is intended to be evaluated. I agree that the _const_ part is a bit odd. What do you think about the cast to u64 alone? I appreciate your feedback. Thanks -- Gustavo