Skip to content

Commit 20c7b42

Browse files
Gax-clumag
authored andcommitted
drm/msm/dpu: cast crtc_clk calculation to u64 in _dpu_core_perf_calc_clk()
There may be a potential integer overflow issue in _dpu_core_perf_calc_clk(). crtc_clk is defined as u64, while mode->vtotal, mode->hdisplay, and drm_mode_vrefresh(mode) are defined as a smaller data type. The result of the calculation will be limited to "int" in this case without correct casting. In screen with high resolution and high refresh rate, integer overflow may happen. So, we recommend adding an extra cast to prevent potential integer overflow. Fixes: c33b7c0 ("drm/msm/dpu: add support for clk and bw scaling for display") Signed-off-by: Zichen Xie <[email protected]> Reviewed-by: Abhinav Kumar <[email protected]> Patchwork: https://patchwork.freedesktop.org/patch/622206/ Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Baryshkov <[email protected]>
1 parent c36a410 commit 20c7b42

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/gpu/drm/msm/disp/dpu1/dpu_core_perf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ static u64 _dpu_core_perf_calc_clk(const struct dpu_perf_cfg *perf_cfg,
8080

8181
mode = &state->adjusted_mode;
8282

83-
crtc_clk = mode->vtotal * mode->hdisplay * drm_mode_vrefresh(mode);
83+
crtc_clk = (u64)mode->vtotal * mode->hdisplay * drm_mode_vrefresh(mode);
8484

8585
drm_atomic_crtc_for_each_plane(plane, crtc) {
8686
pstate = to_dpu_plane_state(plane->state);

0 commit comments

Comments
 (0)