All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/sun4i: reject zero-sized layer
@ 2026-12-05  2:17 Shirong Zhao
  2026-12-05  2:27 ` sashiko-bot
  2026-12-05  2:34 ` [PATCH v2] " Shirong Zhao
  0 siblings, 2 replies; 3+ messages in thread
From: Shirong Zhao @ 2026-12-05  2:17 UTC (permalink / raw)
  To: Chen-Yu Tsai
  Cc: Jernej Skrabec, Samuel Holland, Maxime Ripard, dri-devel,
	linux-sunxi, stable, Shirong Zhao

sun4i_frontend_update_coord(), reached through the frontend path, computes
the scaler factors as

	(luma_width << 16) / state->crtc_w
	(luma_height << 16) / state->crtc_h

state->crtc_w/crtc_h are the userspace atomic plane destination size.  The
DRM core only bounds them from above, and nothing in the sun4i backend
rejects zero, so a commit with a zero destination size divides by zero.

Reject zero-sized layers in sun4i_backend_plane_is_supported().

Fixes: 9026e0d122ac ("drm: Add Allwinner A10 Display Engine support")
Signed-off-by: Shirong Zhao <shxzhaosr@163.com>
---
 drivers/gpu/drm/sun4i/sun4i_backend.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/sun4i/sun4i_backend.c b/drivers/gpu/drm/sun4i/sun4i_backend.c
index f01ab79..0b6505d 100644
--- a/drivers/gpu/drm/sun4i/sun4i_backend.c
+++ b/drivers/gpu/drm/sun4i/sun4i_backend.c
@@ -442,6 +442,13 @@ static bool sun4i_backend_plane_uses_frontend(struct drm_plane_state *state)
 static bool sun4i_backend_plane_is_supported(struct drm_plane_state *state,
 					     bool *uses_frontend)
 {
+	/*
+	 * sun4i_frontend_update_coord() divides by crtc_w/crtc_h, and the DRM
+	 * core does not reject a zero destination size.
+	 */
+	if (!state->crtc_w || !state->crtc_h)
+		return false;
+
 	if (sun4i_backend_plane_uses_frontend(state)) {
 		*uses_frontend = true;
 		return true;
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-12-05  2:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-05  2:17 [PATCH] drm/sun4i: reject zero-sized layer Shirong Zhao
2026-12-05  2:27 ` sashiko-bot
2026-12-05  2:34 ` [PATCH v2] " Shirong Zhao

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.