va: call texture_get_handle while the mutex is being held
authorMarek Olšák <marek.olsak@amd.com>
Wed, 4 Jan 2017 10:42:13 +0000 (11:42 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 4 Jan 2017 16:27:41 +0000 (17:27 +0100)
The context may be used by texture_get_handle.

Reviewed-by: Christian König <christian.koenig@amd.com>
Cc: 13.0 <mesa-stable@lists.freedesktop.org>
src/gallium/state_trackers/va/buffer.c

index 3c9b9d1a1e52479ca00d7ed7fbfb5c9ad82d6eeb..93f012c830f7e5aa9f606c766e4f90b0373f7c90 100644 (file)
@@ -297,15 +297,18 @@ vlVaAcquireBufferHandle(VADriverContextP ctx, VABufferID buf_id,
 
          pipe_mutex_lock(drv->mutex);
          drv->pipe->flush(drv->pipe, NULL, 0);
-         pipe_mutex_unlock(drv->mutex);
 
          memset(&whandle, 0, sizeof(whandle));
          whandle.type = DRM_API_HANDLE_TYPE_FD;
 
          if (!screen->resource_get_handle(screen, drv->pipe,
                                           buf->derived_surface.resource,
-                                          &whandle, PIPE_HANDLE_USAGE_READ_WRITE))
+                                          &whandle, PIPE_HANDLE_USAGE_READ_WRITE)) {
+            pipe_mutex_unlock(drv->mutex);
             return VA_STATUS_ERROR_INVALID_BUFFER;
+         }
+
+         pipe_mutex_unlock(drv->mutex);
 
          buf_info->handle = (intptr_t)whandle.handle;
          break;