From ed8d1d3c9b18172debae808820e6b6a371e7dbc3 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Thu, 5 Sep 2024 11:43:36 -0700 Subject: [PATCH] anv: if queue is NULL in vm_bind return early In the error handling path we end up creating a vk_sync and then later we vk_sync_wait() on it. If that wait fails somehow we'll end up calling vk_queue_set_lost(&queue->vk, ...) which would segfault if queue is NULL. If we end up in this situation (no queue), return directly whatever the backend's vm_bind function returned, propagating the error up if necessary. Fixes: dd5362c78a1 ("anv/xe: try harder when the vm_bind ioctl fails") Reviewed-by: Paulo Zanoni Part-of: --- src/intel/vulkan/anv_sparse.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/intel/vulkan/anv_sparse.c b/src/intel/vulkan/anv_sparse.c index 3a8e1f5152d..28cd3913ad3 100644 --- a/src/intel/vulkan/anv_sparse.c +++ b/src/intel/vulkan/anv_sparse.c @@ -795,11 +795,13 @@ anv_sparse_bind_vm_bind(struct anv_device *device, { struct anv_queue *queue = submit->queue; - if (!queue) - assert(submit->wait_count == 0 && submit->signal_count == 0); - VkResult result = device->kmd_backend->vm_bind(device, submit, ANV_VM_BIND_FLAG_NONE); + if (!queue) { + assert(submit->wait_count == 0 && submit->signal_count == 0 && + submit->binds_len == 1); + return result; + } if (result == VK_ERROR_OUT_OF_HOST_MEMORY) { /* If we get this, the system is under memory pressure. First we