diff mbox

[3/7] sna: check for NULL before dereferencing a pointer

Message ID 1455294689-29249-4-git-send-email-martin.peres@linux.intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Martin Peres Feb. 12, 2016, 4:31 p.m. UTC
Caught by Klockwork and I genuinely can't tell if it is safe without
it, especially since all the surrounding code is checking for NULL.

Signed-off-by: Martin Peres <martin.peres@linux.intel.com>
---
 src/sna/sna_accel.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Chris Wilson Feb. 12, 2016, 4:48 p.m. UTC | #1
On Fri, Feb 12, 2016 at 06:31:25PM +0200, Martin Peres wrote:
> Caught by Klockwork and I genuinely can't tell if it is safe without
> it, especially since all the surrounding code is checking for NULL.

Impossible.
-Chris
diff mbox

Patch

diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c
index 71a6207..8ceb1e1 100644
--- a/src/sna/sna_accel.c
+++ b/src/sna/sna_accel.c
@@ -3688,7 +3688,8 @@  sna_drawable_use_bo(DrawablePtr drawable, unsigned flags, const BoxRec *box,
 	     __FUNCTION__, priv->flush, priv->shm, priv->cpu, flags));
 
 	if ((flags & PREFER_GPU) == 0 &&
-	    (flags & (REPLACES | IGNORE_DAMAGE) || !priv->gpu_damage || !kgem_bo_is_busy(priv->gpu_bo))) {
+	    (flags & (REPLACES | IGNORE_DAMAGE) || !priv->gpu_damage ||
+	     (priv->gpu_bo && !kgem_bo_is_busy(priv->gpu_bo)))) {
 		DBG(("%s: try cpu as GPU bo is idle\n", __FUNCTION__));
 		goto use_cpu_bo;
 	}