diff mbox series

[4/5] drm/i915: Add sanity checks before accessing fb buffer object

Message ID 20240204195207.3616932-5-chaitanya.kumar.borah@intel.com (mailing list archive)
State New, archived
Headers show
Series Cursor Fault Fixes | expand

Commit Message

Chaitanya Kumar Borah Feb. 4, 2024, 7:52 p.m. UTC
Now that cursor plane fb unpinning can be deferred to vblank work
check if plane state and corresponding fb pointers are still valid
before cleanup.

Signed-off-by: Chaitanya Kumar Borah <chaitanya.kumar.borah@intel.com>
---
 drivers/gpu/drm/i915/display/intel_atomic_plane.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.c b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
index a585e4aca309..a0217fef9920 100644
--- a/drivers/gpu/drm/i915/display/intel_atomic_plane.c
+++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
@@ -1171,12 +1171,18 @@  static void
 intel_cleanup_plane_fb(struct drm_plane *plane,
 		       struct drm_plane_state *_old_plane_state)
 {
+	struct drm_i915_private *i915 = to_i915(_old_plane_state->plane->dev);
 	struct intel_plane_state *old_plane_state =
 		to_intel_plane_state(_old_plane_state);
 	struct intel_atomic_state *state =
 		to_intel_atomic_state(old_plane_state->uapi.state);
 	struct drm_i915_private *dev_priv = to_i915(plane->dev);
-	struct drm_i915_gem_object *obj = intel_fb_obj(old_plane_state->hw.fb);
+	struct drm_i915_gem_object *obj = NULL;
+
+	if (old_plane_state && old_plane_state->hw.fb)
+		obj = intel_fb_obj(old_plane_state->hw.fb);
+	else
+		drm_err_ratelimited(&i915->drm, "Invalid plane state or fb\n");
 
 	if (!obj)
 		return;