tegra_dsi_encoder_atomic_check() stores state->vrefresh = drm_mode_vrefresh(&crtc_state->mode) and tegra_dsi_set_timeout() later computes timeout = (bclk / vrefresh) / 512; drm_mode_vrefresh() returns 0 when htotal or vtotal is 0 or when the clock*num or htotal*vtotal*den product overflows, and tegra_dsi_connector_mode_valid() returns MODE_OK unconditionally, so a crafted mode supplied through DRM_IOCTL_MODE_ATOMIC/SETCRTC reaches the division with vrefresh == 0 and raises a divide error. Reject such modes in tegra_dsi_encoder_atomic_check(). Fixes: dec727399a4b ("drm/tegra: Add DSI support") Cc: stable@vger.kernel.org Signed-off-by: Shirong Zhao --- drivers/gpu/drm/tegra/dsi.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/gpu/drm/tegra/dsi.c b/drivers/gpu/drm/tegra/dsi.c index b694c4a..4de0451 100644 --- a/drivers/gpu/drm/tegra/dsi.c +++ b/drivers/gpu/drm/tegra/dsi.c @@ -1000,6 +1000,10 @@ tegra_dsi_encoder_atomic_check(struct drm_encoder *encoder, return err; state->vrefresh = drm_mode_vrefresh(&crtc_state->mode); + if (!state->vrefresh) { + /* drm_mode_vrefresh() returns 0 on overflow or zero h/vtotal */ + return -EINVAL; + } /* compute byte clock */ state->bclk = (state->pclk * state->mul) / (state->div * state->lanes); -- 2.53.0