winsys/drm: Fix assert when try to accumulate an invalid fd
authorCharmaine Lee <charmainel@vmware.com>
Thu, 9 Aug 2018 23:22:52 +0000 (16:22 -0700)
committerBrian Paul <brianp@vmware.com>
Wed, 5 Sep 2018 17:22:42 +0000 (11:22 -0600)
This patch makes sure there is a valid fd before merging it
to the context's fd in vmw_svga_winsys_fence_server_sync().

This fixes the assert running webot.
No regression running kmscube.

Reviewed-by: Sinclair Yeh <syeh@vmware.com>
src/gallium/winsys/svga/drm/vmw_screen_svga.c

index 7c80642b377188de0837ba4cdebec4f5d409302d..27a8b07016613b7e0875c438967b2fbdb2722720 100644 (file)
@@ -158,8 +158,13 @@ vmw_svga_winsys_fence_server_sync(struct svga_winsys_screen *sws,
                                   int32_t *context_fd,
                                   struct pipe_fence_handle *fence)
 {
-   return sync_accumulate("vmwgfx", context_fd,
-                          sws->fence_get_fd(sws, fence, FALSE));
+   int32_t fd = sws->fence_get_fd(sws, fence, FALSE);
+
+   /* If we don't have fd, we don't need to merge fd into the context's fd. */
+   if (fd == -1)
+      return 0;
+
+   return sync_accumulate("vmwgfx", context_fd, fd);
 }