drm/bridge: nwl-dsi: Avoid potential multiplication overflow on 32-bit
authorGeert Uytterhoeven <geert+renesas@glider.be>
Wed, 14 Jul 2021 09:48:06 +0000 (11:48 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 18 Sep 2021 11:40:21 +0000 (13:40 +0200)
commitbe2e11b9f8fab49da85a3d79a34f4436c60510df
tree59380c89aaf46af08c3a3e3f87f64b98b893bb68
parent6a3564739b9f9f0c8df4c0eab3ce888a04e967a4
drm/bridge: nwl-dsi: Avoid potential multiplication overflow on 32-bit

[ Upstream commit 47956bc86ee4e8530cac386a04f62a6095f7afbe ]

As nwl_dsi.lanes is u32, and NSEC_PER_SEC is 1000000000L, the second
multiplication in

    dsi->lanes * 8 * NSEC_PER_SEC

will overflow on a 32-bit platform.  Fix this by making the constant
unsigned long long, forcing 64-bit arithmetic.

As iMX8 is arm64, this driver is currently used on 64-bit platforms
only, where long is 64-bit, so this cannot happen.  But the issue will
start to happen when the driver is reused for a 32-bit SoC (e.g.
i.MX7ULP), or when code is copied for a new driver.

Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Fabio Estevam <festevam@gmail.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/ebb82941a86b4e35c4fcfb1ef5a5cfad7c1fceab.1626255956.git.geert+renesas@glider.be
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/bridge/nwl-dsi.c