]> git.itanic.dy.fi Git - linux-stable/commitdiff
drm/tegra: Avoid potential 32-bit integer overflow
authorNur Hussein <hussein@unixcat.org>
Wed, 5 Apr 2023 20:25:59 +0000 (04:25 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 30 May 2023 11:38:34 +0000 (12:38 +0100)
[ 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 <hussein@unixcat.org>
Signed-off-by: Thierry Reding <treding@nvidia.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/tegra/sor.c

index 352ae52be34188ad6cd790c8316942fc3bff0741..76451c8bfb46b3f45b3bb0a65afbd93e4e4bc7d5 100644 (file)
@@ -709,7 +709,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;