Re: [PATCH v2 4/4] drm/verisilicon: check old state CRTC in plane atomic_disable

From: Thomas Zimmermann

Date: Mon Nov 16 2026 - 08:42:16 EST


Hi

Am 02.11.26 um 08:57 schrieb Icenowy Zheng:
As atomic_update hooks of both planes would utilize atomic_disable
functions to disable the plane when it's set to invisible (even when
technically enabled), the atomic_disable functions need to check whether
the plane is really enabled before.

Why? Why not just disable the plane?

Also see my review of the other patch. Why not remove that disable call from atomic_update?

Best regards
Thomas


Add such a check to prevent NULL dereference.

Fixes: dbf21777caa8 ("drm: verisilicon: add a driver for Verisilicon display controllers")
Fixes: 8c4ae2189125 ("drm: verisilicon: add support for cursor planes")
Signed-off-by: Icenowy Zheng <zhengxingda@xxxxxxxxxxx>
---
drivers/gpu/drm/verisilicon/vs_cursor_plane.c | 13 ++++++++++---
drivers/gpu/drm/verisilicon/vs_primary_plane.c | 13 ++++++++++---
2 files changed, 20 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/verisilicon/vs_cursor_plane.c b/drivers/gpu/drm/verisilicon/vs_cursor_plane.c
index 5295dc2f9ee2e..bee19b65b9a4e 100644
--- a/drivers/gpu/drm/verisilicon/vs_cursor_plane.c
+++ b/drivers/gpu/drm/verisilicon/vs_cursor_plane.c
@@ -104,9 +104,16 @@ static void vs_cursor_plane_atomic_disable(struct drm_plane *plane,
struct drm_plane_state *state = drm_atomic_get_old_plane_state(atomic_state,
plane);
struct drm_crtc *crtc = state->crtc;
- struct vs_crtc *vcrtc = drm_crtc_to_vs_crtc(crtc);
- unsigned int output = vcrtc->id;
- struct vs_dc *dc = vcrtc->dc;
+ struct vs_crtc *vcrtc;
+ unsigned int output;
+ struct vs_dc *dc;
+
+ if (!crtc)
+ return;
+
+ vcrtc = drm_crtc_to_vs_crtc(crtc);
+ output = vcrtc->id;
+ dc = vcrtc->dc;
regmap_update_bits(dc->regs, VSDC_CURSOR_CONFIG(output),
VSDC_CURSOR_CONFIG_FMT_MASK,
diff --git a/drivers/gpu/drm/verisilicon/vs_primary_plane.c b/drivers/gpu/drm/verisilicon/vs_primary_plane.c
index e687313d6f057..01725e60e5fbd 100644
--- a/drivers/gpu/drm/verisilicon/vs_primary_plane.c
+++ b/drivers/gpu/drm/verisilicon/vs_primary_plane.c
@@ -65,9 +65,16 @@ static void vs_primary_plane_atomic_disable(struct drm_plane *plane,
struct drm_plane_state *state = drm_atomic_get_old_plane_state(atomic_state,
plane);
struct drm_crtc *crtc = state->crtc;
- struct vs_crtc *vcrtc = drm_crtc_to_vs_crtc(crtc);
- unsigned int output = vcrtc->id;
- struct vs_dc *dc = vcrtc->dc;
+ struct vs_crtc *vcrtc;
+ unsigned int output;
+ struct vs_dc *dc;
+
+ if (!crtc)
+ return;
+
+ vcrtc = drm_crtc_to_vs_crtc(crtc);
+ output = vcrtc->id;
+ dc = vcrtc->dc;
regmap_clear_bits(dc->regs, VSDC_FB_CONFIG_EX(output),
VSDC_FB_CONFIG_EX_FB_EN);

--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri, (HRB 36809, AG Nürnberg)