From patchwork Tue Jan 30 00:32:21 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: 10191185 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 85BEC60388 for ; Tue, 30 Jan 2018 00:56:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 778BD28446 for ; Tue, 30 Jan 2018 00:56:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6C7D1288FD; Tue, 30 Jan 2018 00:56:57 +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.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable 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 02F8D28446 for ; Tue, 30 Jan 2018 00:56:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752494AbeA3A4z (ORCPT ); Mon, 29 Jan 2018 19:56:55 -0500 Received: from gateway23.websitewelcome.com ([192.185.49.184]:36544 "EHLO gateway23.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752189AbeA3A4z (ORCPT ); Mon, 29 Jan 2018 19:56:55 -0500 X-Greylist: delayed 1473 seconds by postgrey-1.27 at vger.kernel.org; Mon, 29 Jan 2018 19:56:55 EST Received: from cm14.websitewelcome.com (cm14.websitewelcome.com [100.42.49.7]) by gateway23.websitewelcome.com (Postfix) with ESMTP id B113554F0 for ; Mon, 29 Jan 2018 18:32:22 -0600 (CST) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id gJqYeX7o10aRHgJqYesthl; Mon, 29 Jan 2018 18:32:22 -0600 Received: from [189.145.57.174] (port=35460 helo=training) by gator4166.hostgator.com with esmtpa (Exim 4.89_1) (envelope-from ) id 1egJqY-001eaY-AI; Mon, 29 Jan 2018 18:32:22 -0600 Date: Mon, 29 Jan 2018 18:32:21 -0600 From: "Gustavo A. R. Silva" To: Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH 5/8] pci: cx88-input: fix potential integer overflow Message-ID: <7958c3115b5727c2272ce9cf7454cea8e6f4cc50.1517268668.git.gustavo@embeddedor.com> References: MIME-Version: 1.0 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: 1egJqY-001eaY-AI X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: (training) [189.145.57.174]:35460 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 26 X-Source-Cap: Z3V6aWRpbmU7Z3V6aWRpbmU7Z2F0b3I0MTY2Lmhvc3RnYXRvci5jb20= X-Local-Domain: yes Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Cast ir->polling to ktime_t in order to avoid a potential integer overflow. This variable is being used in a context that expects an expression of type ktime_t (s64). Addresses-Coverity-ID: 1392628 ("Unintentional integer overflow") Addresses-Coverity-ID: 1392630 ("Unintentional integer overflow") Signed-off-by: Gustavo A. R. Silva --- drivers/media/pci/cx88/cx88-input.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/pci/cx88/cx88-input.c b/drivers/media/pci/cx88/cx88-input.c index 4e9953e..096b350 100644 --- a/drivers/media/pci/cx88/cx88-input.c +++ b/drivers/media/pci/cx88/cx88-input.c @@ -180,7 +180,7 @@ static enum hrtimer_restart cx88_ir_work(struct hrtimer *timer) struct cx88_IR *ir = container_of(timer, struct cx88_IR, timer); cx88_ir_handle_key(ir); - missed = hrtimer_forward_now(&ir->timer, ir->polling * 1000000); + missed = hrtimer_forward_now(&ir->timer, (ktime_t)ir->polling * 1000000); if (missed > 1) ir_dprintk("Missed ticks %ld\n", missed - 1); @@ -200,7 +200,7 @@ static int __cx88_ir_start(void *priv) if (ir->polling) { hrtimer_init(&ir->timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL); ir->timer.function = cx88_ir_work; - hrtimer_start(&ir->timer, ir->polling * 1000000, + hrtimer_start(&ir->timer, (ktime_t)ir->polling * 1000000, HRTIMER_MODE_REL); } if (ir->sampling) {