st/dri: fix a crash in server_wait_sync
authorMarek Olšák <marek.olsak@amd.com>
Thu, 5 Jul 2018 22:15:31 +0000 (18:15 -0400)
committerMarek Olšák <marek.olsak@amd.com>
Fri, 6 Jul 2018 20:23:37 +0000 (16:23 -0400)
Ported from i965 including the comment.

This fixes:
    dEQP-EGL.functional.reusable_sync.valid.wait_server

Cc: 18.1 <mesa-stable@lists.freedesktop.org>
Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
src/gallium/state_trackers/dri/dri_helpers.c

index f1501bf..5d42873 100644 (file)
@@ -214,6 +214,12 @@ dri2_server_wait_sync(__DRIcontext *_ctx, void *_fence, unsigned flags)
    struct pipe_context *ctx = dri_context(_ctx)->st->pipe;
    struct dri2_fence *fence = (struct dri2_fence*)_fence;
 
+   /* We might be called here with a NULL fence as a result of WaitSyncKHR
+    * on a EGL_KHR_reusable_sync fence. Nothing to do here in such case.
+    */
+   if (!fence)
+      return;
+
    if (ctx->fence_server_sync)
       ctx->fence_server_sync(ctx, fence->pipe_fence);
 }