From dd24ab86cc2e3dc5b3082f17b2902f6abf15c153 Mon Sep 17 00:00:00 2001 From: Illia Abernikhin Date: Mon, 4 Apr 2022 16:37:28 +0300 Subject: [PATCH] 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 Reviewed-by: Lionel Landwerlin Part-of: --- 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,