vulkan: Handle alignment failure in the pipeline cache.
authorEmma Anholt <emma@anholt.net>
Tue, 25 Apr 2023 20:17:26 +0000 (13:17 -0700)
committerMarge Bot <emma+marge@anholt.net>
Wed, 3 May 2023 00:27:49 +0000 (00:27 +0000)
On malloc failure, or more likely a passed in pDataSize < pipeline cache
data size, we should return incomplete.  Otherwise,
vk_pipeline_cache_object_serialize will assertion fail about the start not
being aligned.

Closes: #8868
Fixes: 591da9877900 ("vulkan: Add a common VkPipelineCache implementation")
Reviewed-by: Faith Ekstrand <faith.ekstrand@collabora.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/22700>

src/vulkan/runtime/vk_pipeline_cache.c

index d87438d..95c1a46 100644 (file)
@@ -710,7 +710,10 @@ vk_common_GetPipelineCacheData(VkDevice _device,
          intptr_t data_size_resv = blob_reserve_uint32(&blob);
          blob_write_bytes(&blob, object->key_data, object->key_size);
 
-         blob_align(&blob, VK_PIPELINE_CACHE_BLOB_ALIGN);
+         if (!blob_align(&blob, VK_PIPELINE_CACHE_BLOB_ALIGN)) {
+            result = VK_INCOMPLETE;
+            break;
+         }
 
          uint32_t data_size;
          if (!vk_pipeline_cache_object_serialize(cache, object,