]> git.baikalelectronics.ru Git - kernel.git/commit
drm/sun4i: dsi: Prevent underflow when computing packet sizes
authorSamuel Holland <samuel@sholland.org>
Fri, 12 Aug 2022 03:16:23 +0000 (22:16 -0500)
committerMaxime Ripard <maxime@cerno.tech>
Mon, 15 Aug 2022 07:09:49 +0000 (09:09 +0200)
commit020347d66ca92bf460eb56d10d4e57bc93d3b453
tree35332206361b473cff229cca40c64e6b184b1cee
parentc19c086c250b4b22b8b5aa6ea9925f3f4cc81b14
drm/sun4i: dsi: Prevent underflow when computing packet sizes

Currently, the packet overhead is subtracted using unsigned arithmetic.
With a short sync pulse, this could underflow and wrap around to near
the maximal u16 value. Fix this by using signed subtraction. The call to
max() will correctly handle any negative numbers that are produced.

Apply the same fix to the other timings, even though those subtractions
are less likely to underflow.

Fixes: b92a9b607c64 ("drm/sun4i: Add Allwinner A31 MIPI-DSI controller support")
Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com>
Signed-off-by: Maxime Ripard <maxime@cerno.tech>
Link: https://lore.kernel.org/r/20220812031623.34057-1-samuel@sholland.org
drivers/gpu/drm/sun4i/sun6i_mipi_dsi.c