Received: by 10.223.176.5 with SMTP id f5csp884251wra; Tue, 6 Feb 2018 08:57:54 -0800 (PST) X-Google-Smtp-Source: AH8x226Fd75lfE7Zh43ap4u5P4m658ePYDIgFg6SXBTaQJ4WcvNxgWL8dRE0AFIVQy9B9khw3zP8 X-Received: by 2002:a17:902:9005:: with SMTP id a5-v6mr2985838plp.251.1517936273977; Tue, 06 Feb 2018 08:57:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517936273; cv=none; d=google.com; s=arc-20160816; b=vtFZ28jumj2p6yJMH9Kxnp/gF122LDI1yS+ZFYyFH0N20oCnLeh17UWZO46kRdqywX 6gOnBnKMQJRP+7hTVWUp2ruQHz0/zsGd9QmZiSRuK8Lk1cm62qYtuWVY/zYskpmBRYDh 5etSaUIgoUR2ja1ZKImb2TviQVf/l2PfDk8ZI16mQ16ysvgZLfc8rh1Zz7b1jPzTBYxB Cl9f2M/hyzySRB3aRLUZ6xrqwLq1rO34O+8G8vkiYCbqcw0NUw+t5U4vo8kQ9iNNYsmn BsxdaeThtpiLWf5jFynli5wLh02H13T+ouTLCAIBafGktq6KJXP4pN9KyWfO7ugPZADE lPjQ== 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=suAcRoWKdcIuEsuUTQH8StblWaKlBm7b76gqE0u0gQo=; b=WmcnZDV7P7slRjg0/1E12/ZaJind9A7J+nhkDJ5v3kM+S2w1e9P2P8yj/OdP1IKYmR NDJclYJOPK0d8AQavZGcD+I9bpsmEl5N4qS9J7/h6lR2lxjboVZYchMfnoYRHu631NNy SSpoED/RtScMgPRHoL3tcuM7U9xqPuSKE7EwBKvPlOQNDvZY/8oMW++G+DyyIobmFq/3 94fbRR36RBRltNjO1kMyr2lUo52dZEYq2UdiRAYv4uA81xyK/5GbptqBDuGpPu7fHdDq VvwGasCDi8ALtapFvXp8wsIX0cv1xgspeuDJr+hxzimqeiK7XwATKqvB/hnGaIWHqcas BxFg== 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 c17-v6si1517929plz.700.2018.02.06.08.57.40; Tue, 06 Feb 2018 08:57:53 -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 S1753213AbeBFQzT (ORCPT + 99 others); Tue, 6 Feb 2018 11:55:19 -0500 Received: from gateway24.websitewelcome.com ([192.185.50.66]:12252 "EHLO gateway24.websitewelcome.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753039AbeBFQw0 (ORCPT ); Tue, 6 Feb 2018 11:52:26 -0500 Received: from cm13.websitewelcome.com (cm13.websitewelcome.com [100.42.49.6]) by gateway24.websitewelcome.com (Postfix) with ESMTP id C13525632 for ; Tue, 6 Feb 2018 10:52:25 -0600 (CST) Received: from gator4166.hostgator.com ([108.167.133.22]) by cmsmtp with SMTP id j6TpetQBXBUMKj6Tpewi4I; Tue, 06 Feb 2018 10:52:25 -0600 Received: from [189.175.4.238] (port=46840 helo=embeddedgus) by gator4166.hostgator.com with esmtpa (Exim 4.89_1) (envelope-from ) id 1ej6Tp-000qTZ-Ba; Tue, 06 Feb 2018 10:52:25 -0600 Date: Tue, 6 Feb 2018 10:52:24 -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 v3 7/8] platform: sh_veu: use 64-bit arithmetic instead of 32-bit Message-ID: <502e55a2fd44a61126b639d581c8fa7447eb0e72.1517929336.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.175.4.238 X-Source-L: No X-Exim-ID: 1ej6Tp-000qTZ-Ba X-Source: X-Source-Args: X-Source-Dir: X-Source-Sender: (embeddedgus) [189.175.4.238]:46840 X-Source-Auth: gustavo@embeddedor.com X-Email-Count: 41 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 left and top to dma_addr_t in order to give the compiler complete information about the proper arithmetic to use. Notice that these variables are being used in contexts that expect expressions of type dma_addr_t (64 bit, unsigned). Such expressions are currently being evaluated using 32-bit arithmetic. Also, move the expression (((dma_addr_t)left * veu->vfmt_out.fmt->depth) >> 3) at the end in order to avoid a line wrapping checkpatch.pl warning. Addresses-Coverity-ID: 1056807 ("Unintentional integer overflow") Addresses-Coverity-ID: 1056808 ("Unintentional integer overflow") Signed-off-by: Gustavo A. R. Silva --- Changes in v2: - Update subject and changelog to better reflect the proposed code changes. - Move the expression (((dma_addr_t)left * veu->vfmt_out.fmt->depth) >> 3) at the end in order to avoid a line wrapping checkpatch.pl warning. Changes in v3: - Mention the specific Coverity reports in the commit message. drivers/media/platform/sh_veu.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/sh_veu.c b/drivers/media/platform/sh_veu.c index 976ea0b..1a0cde0 100644 --- a/drivers/media/platform/sh_veu.c +++ b/drivers/media/platform/sh_veu.c @@ -520,8 +520,8 @@ static void sh_veu_colour_offset(struct sh_veu_dev *veu, struct sh_veu_vfmt *vfm /* dst_left and dst_top validity will be verified in CROP / COMPOSE */ unsigned int left = vfmt->frame.left & ~0x03; unsigned int top = vfmt->frame.top; - dma_addr_t offset = ((left * veu->vfmt_out.fmt->depth) >> 3) + - top * veu->vfmt_out.bytesperline; + dma_addr_t offset = (dma_addr_t)top * veu->vfmt_out.bytesperline + + (((dma_addr_t)left * veu->vfmt_out.fmt->depth) >> 3); unsigned int y_line; vfmt->offset_y = offset; -- 2.7.4