The plane state in __drm_gem_reset_shadow_plane) can be NULL. Do not
deref that pointer, but forward NULL to the other plane-reset helpers.
Clears plane->state to NULL.

Signed-off-by: Thomas Zimmermann <[email protected]>
Fixes: b71565022031 ("drm/gem: Export implementation of shadow-plane helpers")
Reported-by: Dan Carpenter <[email protected]>
Closes: https://lore.kernel.org/dri-devel/[email protected]/
Cc: Thomas Zimmermann <[email protected]>
Cc: Melissa Wen <[email protected]>
Cc: Maarten Lankhorst <[email protected]>
Cc: Maxime Ripard <[email protected]>
Cc: David Airlie <[email protected]>
Cc: Simona Vetter <[email protected]>
Cc: [email protected]
Cc: <[email protected]> # v5.15+
---
 drivers/gpu/drm/drm_gem_atomic_helper.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/drm_gem_atomic_helper.c 
b/drivers/gpu/drm/drm_gem_atomic_helper.c
index ebf305fb24f0..6fb55601252f 100644
--- a/drivers/gpu/drm/drm_gem_atomic_helper.c
+++ b/drivers/gpu/drm/drm_gem_atomic_helper.c
@@ -310,8 +310,12 @@ EXPORT_SYMBOL(drm_gem_destroy_shadow_plane_state);
 void __drm_gem_reset_shadow_plane(struct drm_plane *plane,
                                  struct drm_shadow_plane_state 
*shadow_plane_state)
 {
-       __drm_atomic_helper_plane_reset(plane, &shadow_plane_state->base);
-       drm_format_conv_state_init(&shadow_plane_state->fmtcnv_state);
+       if (shadow_plane_state) {
+               __drm_atomic_helper_plane_reset(plane, 
&shadow_plane_state->base);
+               drm_format_conv_state_init(&shadow_plane_state->fmtcnv_state);
+       } else {
+               __drm_atomic_helper_plane_reset(plane, NULL);
+       }
 }
 EXPORT_SYMBOL(__drm_gem_reset_shadow_plane);
 
-- 
2.51.0

Reply via email to