In cases where old_state may not be present we hit a null dereference.
Add a check to fix this and also do an early return if there is no
new_state or crtc since there is nothing to do in that case.
This fixes igt test kms_cursor_legacy@torture-bo.
Fixes: 965544150d1c ("drm/vmwgfx: Refactor cursor handling")
Cc: Zack Rusin <[email protected]>
Cc: Broadcom internal kernel review list <[email protected]>
Cc: [email protected]
Signed-off-by: Maaz Mombasawala <[email protected]>
---
drivers/gpu/drm/vmwgfx/vmwgfx_cursor_plane.c | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_cursor_plane.c
b/drivers/gpu/drm/vmwgfx/vmwgfx_cursor_plane.c
index b010fc7ca68e..583115c94800 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_cursor_plane.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_cursor_plane.c
@@ -742,11 +742,17 @@ vmw_cursor_plane_atomic_update(struct drm_plane *plane,
struct drm_atomic_commit *state)
{
struct vmw_bo *bo;
- struct drm_plane_state *new_state =
- drm_atomic_get_new_plane_state(state, plane);
- struct drm_plane_state *old_state =
- drm_atomic_get_old_plane_state(state, plane);
- struct drm_crtc *crtc = new_state->crtc ?: old_state->crtc;
+ struct drm_plane_state *new_state;
+ struct drm_plane_state *old_state;
+
+ new_state = drm_atomic_get_new_plane_state(state, plane);
+ if (!new_state)
+ return;
+ old_state = drm_atomic_get_old_plane_state(state, plane);
+ struct drm_crtc *crtc = new_state->crtc ? new_state->crtc :
+ (old_state ? old_state->crtc : NULL);
+ if (!crtc)
+ return;
struct vmw_private *dev_priv = vmw_priv(plane->dev);
struct vmw_display_unit *du = vmw_crtc_to_du(crtc);
struct vmw_plane_state *vps = vmw_plane_state_to_vps(new_state);
--
2.54.0