Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 4A3F0C77B7F for ; Mon, 1 May 2023 03:06:27 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1251410E2D2; Mon, 1 May 2023 03:06:26 +0000 (UTC) Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by gabe.freedesktop.org (Postfix) with ESMTPS id 254C810E2D0 for ; Mon, 1 May 2023 03:06:25 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id A00BD61824; Mon, 1 May 2023 03:06:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 488FDC4339E; Mon, 1 May 2023 03:06:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1682910384; bh=yipB3oG9ljdWOvL43OW9E5E3JcaudM8pbeZSWeSc0/g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oZL1NAG/BOlzlimHz3Q/vmWU/sm5P2+bhWsRozAG2sceLKOxihGShohQebVoHZYJq dQ1PjB/BABaT5ZeaH6G9nvEd90EUvLdleSoqGMnwc3O6I9SpZ0Cvaeab6NhDLAVp/a JnF1WefEJGK2UKPPxIXJ84rVdwXk7+aDnzi2r2/uqy8JyQSpMVpmbDRtBeYe0cpBPU RbSXmvlhowWyepApr8tL8+80/yzo1yQiXG4Xy5e3wRkEk8DupzfvttWVBEK04rTPZz YLGkPzNdHfvtGHirjvupFBRnyUjhWdFwsYMH9zpwabSyCwf9anI9fVL/yKtxeXN69A sRv6Ft2V1nZqA== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH AUTOSEL 5.4 6/9] drm/tegra: Avoid potential 32-bit integer overflow Date: Sun, 30 Apr 2023 23:06:06 -0400 Message-Id: <20230501030611.3255082-6-sashal@kernel.org> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230501030611.3255082-1-sashal@kernel.org> References: <20230501030611.3255082-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Sasha Levin , Nur Hussein , jonathanh@nvidia.com, dri-devel@lists.freedesktop.org, mperttunen@nvidia.com, thierry.reding@gmail.com, linux-tegra@vger.kernel.org, Thierry Reding Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Nur Hussein [ Upstream commit 2429b3c529da29d4277d519bd66d034842dcd70c ] In tegra_sor_compute_config(), the 32-bit value mode->clock is multiplied by 1000, and assigned to the u64 variable pclk. We can avoid a potential 32-bit integer overflow by casting mode->clock to u64 before we do the arithmetic and assignment. Signed-off-by: Nur Hussein Signed-off-by: Thierry Reding Signed-off-by: Sasha Levin --- drivers/gpu/drm/tegra/sor.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/tegra/sor.c b/drivers/gpu/drm/tegra/sor.c index 0419b6105c8a5..ccd084abc8c94 100644 --- a/drivers/gpu/drm/tegra/sor.c +++ b/drivers/gpu/drm/tegra/sor.c @@ -906,7 +906,7 @@ static int tegra_sor_compute_config(struct tegra_sor *sor, struct drm_dp_link *link) { const u64 f = 100000, link_rate = link->rate * 1000; - const u64 pclk = mode->clock * 1000; + const u64 pclk = (u64)mode->clock * 1000; u64 input, output, watermark, num; struct tegra_sor_params params; u32 num_syms_per_line; -- 2.39.2