Mesa (main): vulkan/runtime: repair thread safety in method vk_queue_start_submit_thread()

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Apr 22 14:38:09 UTC 2022


Module: Mesa
Branch: main
Commit: dd24ab86cc2e3dc5b3082f17b2902f6abf15c153
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=dd24ab86cc2e3dc5b3082f17b2902f6abf15c153

Author: Illia Abernikhin <illia.abernikhin at globallogic.com>
Date:   Mon Apr  4 16:37:28 2022 +0300

vulkan/runtime: repair thread safety in method vk_queue_start_submit_thread()

Accessing queue->submit.thread_run without holding lock vk_queue.submit.mutex.
Elsewhere, vk_queue.submit.thread_run is accessed with vk_queue.mutex
held 1 out of 2 times (1 of these accesses strongly imply that it is necessary).

Found by Coverity.
CID: 1503334

Signed-off-by: Illia Abernikhin <illia.abernikhin at globallogic.com>
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15736>

---

 src/vulkan/runtime/vk_queue.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/vulkan/runtime/vk_queue.c b/src/vulkan/runtime/vk_queue.c
index 6216af9d856..9c1df73aed8 100644
--- a/src/vulkan/runtime/vk_queue.c
+++ b/src/vulkan/runtime/vk_queue.c
@@ -520,7 +520,9 @@ vk_queue_start_submit_thread(struct vk_queue *queue)
 {
    int ret;
 
+   mtx_lock(&queue->submit.mutex);
    queue->submit.thread_run = true;
+   mtx_unlock(&queue->submit.mutex);
 
    ret = thrd_create(&queue->submit.thread,
                      vk_queue_submit_thread_func,



More information about the mesa-commit mailing list