winsys/radeon: Only add bo to hash table when creating flink
authorMartin Andersson <g02maran@gmail.com>
Fri, 1 Mar 2013 21:34:28 +0000 (22:34 +0100)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 1 Mar 2013 22:52:40 +0000 (17:52 -0500)
The problem is that we mix bo handles and flinked names in the hash
table. Because kms type handles are not flinked they should not be
added to the hash table. If we do that we will sooner or later
get a situation where we will overwrite a correct entry because
the bo handle was the same as a flinked name.

Note: this is a candidate for the stable branches.

Reviewed-by: Jerome Glisse <jglisse@redhat.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
src/gallium/winsys/radeon/drm/radeon_drm_bo.c

index 2d41c267ff7eed4afbfed592ec1136726b7eca6b..f4ac526ed889af075c9d40c22ce29ebc2b49728c 100644 (file)
@@ -957,16 +957,16 @@ static boolean radeon_winsys_bo_get_handle(struct pb_buffer *buffer,
 
             bo->flinked = TRUE;
             bo->flink = flink.name;
+
+            pipe_mutex_lock(bo->mgr->bo_handles_mutex);
+            util_hash_table_set(bo->mgr->bo_handles, (void*)(uintptr_t)bo->flink, bo);
+            pipe_mutex_unlock(bo->mgr->bo_handles_mutex);
         }
         whandle->handle = bo->flink;
     } else if (whandle->type == DRM_API_HANDLE_TYPE_KMS) {
         whandle->handle = bo->handle;
     }
 
-    pipe_mutex_lock(bo->mgr->bo_handles_mutex);
-    util_hash_table_set(bo->mgr->bo_handles, (void*)(uintptr_t)whandle->handle, bo);
-    pipe_mutex_unlock(bo->mgr->bo_handles_mutex);
-
     whandle->stride = stride;
     return TRUE;
 }