Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1658228pxb; Wed, 10 Feb 2021 13:32:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJy6+r/WTfUuo2WzHIOueEkZuqMAPGPPXe/9XbdYp+CUXhVRrMSp049yAXTcTCLLxo9z61SG X-Received: by 2002:a17:906:c9cc:: with SMTP id hk12mr5139629ejb.134.1612992734211; Wed, 10 Feb 2021 13:32:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612992734; cv=none; d=google.com; s=arc-20160816; b=dCT/1bxJWOyvvbOwOkTvTNKBZANS2uaUE2qqteKm05bn75ZaAnAF/Q/MC38nHoeYFo F8tdut2kCyCZuCKIaE4g2tmRdPJvUuWtCjXSKYWUl2pb6/V3x9qFG20H5pKzdsl8s8X4 IKb4L/aRqk/4aTaeK8X39QZ+VSwQZ8VUdtl3UcvnPFLEzWV5jrLRYm1FdmptqVUS4iQO C32o1QZlETYEMNK9yv2OOjfFPes+twnEKvkfF1165k6OkAzTdcgkjr60IULoq3z8pZf7 R8xoA5yP25BYO6M029ats3tZYzHBc+GWd/S5ggU53EdANlEii//pzt2RaXyxBpqxsX2d QZiQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=fwqWGTO+LFY02W98PJDAYkCwu3f9obgm1ZCEqj1DLfI=; b=ojU2KmH87CQZe73lVlDHWv+EF45QlJpRBGVg1q6VtuKbqa1FmGmlsUGsK4uQxERPH0 PyNq9KEJXIJHIZkDHbnAZuz1kztwfLl0POgROUXy1bPnXJqPAbGTpuk1xIED5bgVY3hF 162pbFZpBDXbVMJFTphTSyIl0AiODvncj/CJ7/2cypNPH47UQja6mJibavj3QjK3f5dr AtVLezIwvnoL38RG3ImTRj0fvKxR/fKRgaDhZ3HkDMXpQOmTOjLay8eWGqoWlO94ho6o tTryFKR//X7qRibDkU5s7NGS6BHBLkj825vERYsLNCQFdbwNf/UeftYHZaB8DhEGSgCw P1tQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BqgEJkVC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j15si2188628edy.105.2021.02.10.13.31.50; Wed, 10 Feb 2021 13:32:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=BqgEJkVC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233736AbhBJV2w (ORCPT + 99 others); Wed, 10 Feb 2021 16:28:52 -0500 Received: from mail.kernel.org ([198.145.29.99]:54718 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233298AbhBJVYP (ORCPT ); Wed, 10 Feb 2021 16:24:15 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8865A64E25; Wed, 10 Feb 2021 21:23:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1612992213; bh=k3bbAR+QQBOR7zd9whmQpQntZ79/acFM/RObzEoAatE=; h=Date:From:To:Cc:Subject:From; b=BqgEJkVCl0KGcfVOtXDwLivOod3poKWl51r6qsc1KvoGcbt2+SMFUVP7Pn33CoPtx 4BTBUxGWmk3jirdxVDFeqeLr0lYHm9c3MYOANm+2xiL4KBiSY7gseZEAIDdm92aSQ1 5NISc/OT1CVUYEmOJ5d2WHKsGYUDvC5QlSc7n7s/7+67IVg3k00gFYjyuDwA7lm5Gu 1dTeSOnBYXVLq2ZKlqalDU+mZOXAvb6TvObkSKCHqtR1MIxnvWsDkrkwWE/lEB7th0 6YSOov/V1LzFUuSQrmkQbr+mBDrX8YiAq9nUhn5/xJGwOOHYrevHtdMMxn0vZXoTgM cksH2GFNWTrpg== Date: Wed, 10 Feb 2021 15:23:30 -0600 From: "Gustavo A. R. Silva" To: Harry Wentland , Leo Li , Alex Deucher , Christian =?iso-8859-1?Q?K=F6nig?= , David Airlie , Daniel Vetter , Huang Rui , Anson Jacob , Lang Yu , Nicholas Kazlauskas Cc: amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, "Gustavo A. R. Silva" Subject: [PATCH][next] drm/amd/display: Fix potential integer overflow Message-ID: <20210210212330.GA880153@embeddedor> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fix potential integer overflow by casting actual_calculated_clock_100hz to u64, in order to give the compiler complete information about the proper arithmetic to use. Notice that such variable is used in a context that expects an expression of type u64 (64 bits, unsigned) and the following expression is currently being evaluated using 32-bit arithmetic: actual_calculated_clock_100hz * post_divider Fixes: 7a03fdf628af ("drm/amd/display: fix 64bit division issue on 32bit OS") Addresses-Coverity-ID: 1501691 ("Unintentional integer overflow") Signed-off-by: Gustavo A. R. Silva --- drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c b/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c index bc942725b9d8..dec58b3c42e4 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c @@ -240,7 +240,7 @@ static bool calc_fb_divider_checking_tolerance( pll_settings->calculated_pix_clk_100hz = actual_calculated_clock_100hz; pll_settings->vco_freq = - div_u64(actual_calculated_clock_100hz * post_divider, 10); + div_u64((u64)actual_calculated_clock_100hz * post_divider, 10); return true; } return false; -- 2.27.0