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

* Re: [PATCH] drm/sun4i: reject zero-sized layer
  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
  1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-12-05  2:27 UTC (permalink / raw)
  To: Shirong Zhao; +Cc: dri-devel, linux-sunxi

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Low] drm/sun4i: Fixes trailer cites commit predating frontend
  divide-by-zero
--

commit 38f14c080ffeebc7f15d4cfb56f927a9e17b180b
Author: Shirong Zhao <shxzhaosr@163.com>

> drm/sun4i: reject zero-sized layer
>
> 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>

[Severity: Low]
Does the Fixes tag point to the right commit?  9026e0d122ac ("drm: Add
Allwinner A10 Display Engine support") predates the display frontend and
sun4i_frontend_update_coord(), which misdirects stable backport tracking.

The division by state->crtc_w and state->crtc_h was introduced in
dd0421f47505 ("drm/sun4i: Add a driver for the display frontend") and
enabled via 96180dde23b7 ("drm/sun4i: backend: Add a custom atomic_check
for the frontend").  Should this be:

  Fixes: 96180dde23b7 ("drm/sun4i: backend: Add a custom atomic_check for the frontend")

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261205021741.44-1-shxzhaosr@163.com?part=1

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

* [PATCH v2] drm/sun4i: reject zero-sized layer
  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 ` Shirong Zhao
  1 sibling, 0 replies; 3+ messages in thread
From: Shirong Zhao @ 2026-12-05  2:34 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: dd0421f47505 ("drm/sun4i: Add a driver for the display frontend")
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.