sti_hqvdp_check_hw_scaling() computes lfw /= max(src_w, dst_w) * mode->clock / 1000; inv_zy = DIV_ROUND_UP(src_h, dst_h); src_w/src_h and dst_w/dst_h come from the atomic plane state (crtc_w/crtc_h and src_w/src_h, the latter shifted down from 16.16). dst_w/dst_h are clamped to [0, ...] and src_* can be 0, and this helper is called before the MIN_WIDTH/MIN_HEIGHT size validation. A zero max(src_w, dst_w), a mode clock below 1000, or a zero dst_h therefore divides by zero. Return false (which makes the caller reject the mode) when any of those denominators would be zero. Fixes: 4fdbc678fe4d ("drm: sti: add HQVDP plane") Cc: stable@vger.kernel.org Signed-off-by: Shirong Zhao --- drivers/gpu/drm/sti/sti_hqvdp.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/gpu/drm/sti/sti_hqvdp.c b/drivers/gpu/drm/sti/sti_hqvdp.c index 360d213..ad07ad0 100644 --- a/drivers/gpu/drm/sti/sti_hqvdp.c +++ b/drivers/gpu/drm/sti/sti_hqvdp.c @@ -741,8 +741,12 @@ static bool sti_hqvdp_check_hw_scaling(struct sti_hqvdp *hqvdp, unsigned int inv_zy; lfw = mode->htotal * (clk_get_rate(hqvdp->clk) / 1000000); + if (!max(src_w, dst_w) || mode->clock < 1000) + return false; lfw /= max(src_w, dst_w) * mode->clock / 1000; + if (!dst_h) + return false; inv_zy = DIV_ROUND_UP(src_h, dst_h); return inv_zy <= lfw; -- 2.53.0