public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: oscar.mateo@intel.com
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH] drm/i915: Gracefully handle obj not bound to GGTT in is_pin_display
Date: Wed,  2 Apr 2014 19:21:01 +0100	[thread overview]
Message-ID: <1396462861-16396-1-git-send-email-oscar.mateo@intel.com> (raw)

From: Oscar Mateo <oscar.mateo@intel.com>

Otherwise, we do a NULL pointer dereference.

I've seen this happen while handling an error in
i915_gem_object_pin_to_display_plane():

If i915_gem_object_set_cache_level() fails, we call is_pin_display() to
handle the error. At this point, the object is still not pinned to GGTT
and maybe not even bound, so we have to check before we dereference its
GGTT vma.

Issue: VIZ-3772
Signed-off-by: Oscar Mateo <oscar.mateo@intel.com>
---
 drivers/gpu/drm/i915/i915_gem.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index c70121d..1d161c7 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -3619,6 +3619,10 @@ unlock:
 
 static bool is_pin_display(struct drm_i915_gem_object *obj)
 {
+	struct i915_vma *vma = i915_gem_obj_to_ggtt(obj);
+	if (!vma)
+		return false;
+
 	/* There are 3 sources that pin objects:
 	 *   1. The display engine (scanouts, sprites, cursors);
 	 *   2. Reservations for execbuffer;
@@ -3630,7 +3634,7 @@ static bool is_pin_display(struct drm_i915_gem_object *obj)
 	 * subtracting the potential reference by the user, any pin_count
 	 * remains, it must be due to another use by the display engine.
 	 */
-	return i915_gem_obj_to_ggtt(obj)->pin_count - !!obj->user_pin_count;
+	return vma->pin_count - !!obj->user_pin_count;
 }
 
 /*
-- 
1.9.0

             reply	other threads:[~2014-04-02 17:47 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-04-02 18:21 oscar.mateo [this message]
2014-04-02 17:59 ` [PATCH] drm/i915: Gracefully handle obj not bound to GGTT in is_pin_display Chris Wilson
2014-04-03  9:34 ` Daniel Vetter
2014-05-12  9:05   ` Mateo Lozano, Oscar
2014-05-12 10:09     ` Chris Wilson
2014-05-12 10:30       ` Mateo Lozano, Oscar
2014-05-12 10:37         ` Chris Wilson
2014-05-12 16:11     ` Daniel Vetter
2014-05-12 16:14       ` Daniel Vetter
2014-05-12 17:10         ` Mateo Lozano, Oscar
2014-05-15 13:14         ` Mateo Lozano, Oscar
2014-05-15 13:33           ` Ville Syrjälä
2014-05-16 10:43             ` Mateo Lozano, Oscar
2014-05-15 13:45           ` Daniel Vetter
2014-05-16 11:08 ` [PATCH v2] " oscar.mateo
2014-05-16 11:26   ` Chris Wilson
2014-05-16 13:20   ` [PATCH v3] " oscar.mateo
2014-05-16 14:25     ` Daniel Vetter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1396462861-16396-1-git-send-email-oscar.mateo@intel.com \
    --to=oscar.mateo@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox