malidp_crtc_atomic_check() converts the source size to U32.32 and divides the destination size by it: h_upscale_factor = div_u64((u64)pstate->crtc_w << 32, pstate->src_w); v_upscale_factor = div_u64((u64)pstate->crtc_h << 32, pstate->src_h); src_w/src_h come straight from the userspace atomic plane state. malidp_de_plane_check() validates crtc_w/crtc_h but not src_w/src_h, and drm_atomic_plane_check() only bounds the source rectangle from above, so a DRM atomic commit with SRC_W or SRC_H set to 0 reaches this division and raises a divide error. Reject a zero source size in malidp_de_plane_check(). Fixes: ad49f8602fe8 ("drm/arm: Add support for Mali Display Processors") Cc: stable@vger.kernel.org Signed-off-by: Shirong Zhao --- drivers/gpu/drm/arm/malidp_planes.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/gpu/drm/arm/malidp_planes.c b/drivers/gpu/drm/arm/malidp_planes.c index 38db3d1..8673fa5 100644 --- a/drivers/gpu/drm/arm/malidp_planes.c +++ b/drivers/gpu/drm/arm/malidp_planes.c @@ -542,6 +542,14 @@ static int malidp_de_plane_check(struct drm_plane *plane, (new_plane_state->crtc_h < mp->hwdev->min_line_size)) return -EINVAL; + /* + * malidp_crtc_atomic_check() divides crtc_w/crtc_h by src_w/src_h, so a + * zero source rectangle would be a divide by zero. The core only bounds + * src_w/src_h from above. + */ + if (!new_plane_state->src_w || !new_plane_state->src_h) + return -EINVAL; + /* * DP550/650 video layers can accept 3 plane formats only if * fb->pitches[1] == fb->pitches[2] since they don't have a -- 2.53.0