Mesa (master): anv: Add error handling to setup_empty_execbuf().

Francisco Jerez currojerez at kemper.freedesktop.org
Tue Aug 22 19:04:07 UTC 2017


Module: Mesa
Branch: master
Commit: 7ca124a6a3987fbfc09bc530761d44714c0da773
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=7ca124a6a3987fbfc09bc530761d44714c0da773

Author: Francisco Jerez <currojerez at riseup.net>
Date:   Fri Aug 18 11:00:42 2017 -0700

anv: Add error handling to setup_empty_execbuf().

The anv_execbuf_add_bo() call can actually fail in practice, which
should cause the QueueSubmit operation to fail.  Reported by Coverity.

CID: 1416606: Unchecked return value (CHECKED_RETURN)
Fixes: 017cdb10cf (anv: Submit a dummy batch when only semaphores are provided.)
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin at intel.com>

---

 src/intel/vulkan/anv_batch_chain.c | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)

diff --git a/src/intel/vulkan/anv_batch_chain.c b/src/intel/vulkan/anv_batch_chain.c
index 0078cc5142..26b5375903 100644
--- a/src/intel/vulkan/anv_batch_chain.c
+++ b/src/intel/vulkan/anv_batch_chain.c
@@ -1424,11 +1424,13 @@ setup_execbuf_for_cmd_buffer(struct anv_execbuf *execbuf,
    return VK_SUCCESS;
 }
 
-static void
+static VkResult
 setup_empty_execbuf(struct anv_execbuf *execbuf, struct anv_device *device)
 {
-   anv_execbuf_add_bo(execbuf, &device->trivial_batch_bo, NULL, 0,
-                      &device->alloc);
+   VkResult result = anv_execbuf_add_bo(execbuf, &device->trivial_batch_bo,
+                                        NULL, 0, &device->alloc);
+   if (result != VK_SUCCESS)
+      return result;
 
    execbuf->execbuf = (struct drm_i915_gem_execbuffer2) {
       .buffers_ptr = (uintptr_t) execbuf->objects,
@@ -1439,6 +1441,8 @@ setup_empty_execbuf(struct anv_execbuf *execbuf, struct anv_device *device)
       .rsvd1 = device->context_id,
       .rsvd2 = 0,
    };
+
+   return VK_SUCCESS;
 }
 
 VkResult
@@ -1541,13 +1545,13 @@ anv_cmd_buffer_execbuf(struct anv_device *device,
       }
    }
 
-   if (cmd_buffer) {
+   if (cmd_buffer)
       result = setup_execbuf_for_cmd_buffer(&execbuf, cmd_buffer);
-      if (result != VK_SUCCESS)
-         return result;
-   } else {
-      setup_empty_execbuf(&execbuf, device);
-   }
+   else
+      result = setup_empty_execbuf(&execbuf, device);
+
+   if (result != VK_SUCCESS)
+      return result;
 
    if (execbuf.fence_count > 0) {
       assert(device->instance->physicalDevice.has_syncobj);




More information about the mesa-commit mailing list