diff options
author | Geert Uytterhoeven <geert+renesas@glider.be> | 2021-07-14 11:48:06 +0200 |
---|---|---|
committer | Sam Ravnborg <sam@ravnborg.org> | 2021-07-25 14:15:18 +0200 |
commit | 47956bc86ee4e8530cac386a04f62a6095f7afbe (patch) | |
tree | 1c3f48e19ecfd084870e7515f4deba2a8f9ed397 /drivers/gpu/drm/bridge | |
parent | 6474e67eabfbb6db138820e514f068c2884d1049 (diff) | |
download | linux-47956bc86ee4e8530cac386a04f62a6095f7afbe.tar.gz linux-47956bc86ee4e8530cac386a04f62a6095f7afbe.tar.bz2 linux-47956bc86ee4e8530cac386a04f62a6095f7afbe.zip |
drm/bridge: nwl-dsi: Avoid potential multiplication overflow on 32-bit
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
Diffstat (limited to 'drivers/gpu/drm/bridge')
-rw-r--r-- | drivers/gpu/drm/bridge/nwl-dsi.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/gpu/drm/bridge/nwl-dsi.c b/drivers/gpu/drm/bridge/nwl-dsi.c index d7986067eefe..ed8ac5059cd2 100644 --- a/drivers/gpu/drm/bridge/nwl-dsi.c +++ b/drivers/gpu/drm/bridge/nwl-dsi.c @@ -190,7 +190,7 @@ static u32 ps2bc(struct nwl_dsi *dsi, unsigned long long ps) u32 bpp = mipi_dsi_pixel_format_to_bpp(dsi->format); return DIV64_U64_ROUND_UP(ps * dsi->mode.clock * bpp, - dsi->lanes * 8 * NSEC_PER_SEC); + dsi->lanes * 8ULL * NSEC_PER_SEC); } /* |