Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/msm/dsi: fix 32-bit signed integer extension in pclk_rate calculation

When (mode->clock * 1000) is larger than (1<<31), int to unsigned long
conversion will sign extend the int to 64 bits and the pclk_rate value
will be incorrect.

Fix this by making the result of the multiplication unsigned.

Note that above (1<<32) would still be broken and require more changes, but
its unlikely anyone will need that anytime soon.

Fixes: c4d8cfe516dc ("drm/msm/dsi: add implementation for helper functions")
Signed-off-by: Jonathan Marek <jonathan@marek.ca>
Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org>
Reviewed-by: Abhinav Kumar <quic_abhinavk@quicinc.com>
Patchwork: https://patchwork.freedesktop.org/patch/618434/
Link: https://lore.kernel.org/r/20241007050157.26855-2-jonathan@marek.ca
Signed-off-by: Abhinav Kumar <quic_abhinavk@quicinc.com>

authored by

Jonathan Marek and committed by
Abhinav Kumar
358b7624 24436a54

+1 -1
+1 -1
drivers/gpu/drm/msm/dsi/dsi_host.c
··· 550 550 { 551 551 unsigned long pclk_rate; 552 552 553 - pclk_rate = mode->clock * 1000; 553 + pclk_rate = mode->clock * 1000u; 554 554 555 555 if (dsc) 556 556 pclk_rate = dsi_adjust_pclk_for_compression(mode, dsc);