winsys/radeon: check null return from radeon_cs_create_fence in cs_flush
authorJulien Isorce <julien.isorce@gmail.com>
Fri, 10 Mar 2017 17:20:56 +0000 (17:20 +0000)
committerMarek Olšák <marek.olsak@amd.com>
Mon, 13 Mar 2017 16:19:29 +0000 (17:19 +0100)
Follow-up of patch:
"radeon_cs_create_fence: check null return from radeon_winsys_bo_create"

radeon_drm_cs_flush
  radeon_cs_create_fence
    radeon_winsys_bo_create

Signed-off-by: Julien Isorce <jisorce@oblong.com>
Signed-off-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/winsys/radeon/drm/radeon_drm_cs.c

index 1545fd826373751bed5ac2342eb451d51f56816d..f59b5399e4c5f9d94484d393921aaeb5aa6105a1 100644 (file)
@@ -593,18 +593,20 @@ static int radeon_drm_cs_flush(struct radeon_winsys_cs *rcs,
             fence = radeon_cs_create_fence(rcs);
         }
 
-        if (pfence)
-            radeon_fence_reference(pfence, fence);
-
-        mtx_lock(&cs->ws->bo_fence_lock);
-        for (unsigned i = 0; i < cs->csc->num_slab_buffers; ++i) {
-            struct radeon_bo *bo = cs->csc->slab_buffers[i].bo;
-            p_atomic_inc(&bo->num_active_ioctls);
-            radeon_bo_slab_fence(bo, (struct radeon_bo *)fence);
-        }
-        mtx_unlock(&cs->ws->bo_fence_lock);
+        if (fence) {
+            if (pfence)
+                radeon_fence_reference(pfence, fence);
+
+            mtx_lock(&cs->ws->bo_fence_lock);
+            for (unsigned i = 0; i < cs->csc->num_slab_buffers; ++i) {
+                struct radeon_bo *bo = cs->csc->slab_buffers[i].bo;
+                p_atomic_inc(&bo->num_active_ioctls);
+                radeon_bo_slab_fence(bo, (struct radeon_bo *)fence);
+            }
+            mtx_unlock(&cs->ws->bo_fence_lock);
 
-        radeon_fence_reference(&fence, NULL);
+            radeon_fence_reference(&fence, NULL);
+        }
     } else {
         radeon_fence_reference(&cs->next_fence, NULL);
     }