From 792cf1caffd0ed87f714678b9aba913c829edb3f Mon Sep 17 00:00:00 2001 From: Karmjit Mahil Date: Fri, 5 May 2023 14:06:02 +0100 Subject: [PATCH] pvr: Fix possible allocation of 0 size Some tests had `input_count == 0` so the driver would attempt to `vk_alloc()` a size of zero and error out. Add some checks to prevent that. Signed-off-by: Karmjit Mahil Reviewed-by: Frank Binns Part-of: --- src/imagination/vulkan/pvr_hw_pass.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/imagination/vulkan/pvr_hw_pass.c b/src/imagination/vulkan/pvr_hw_pass.c index dccb9d5c644..f3e9be87ca5 100644 --- a/src/imagination/vulkan/pvr_hw_pass.c +++ b/src/imagination/vulkan/pvr_hw_pass.c @@ -821,6 +821,9 @@ pvr_copy_storage_details(struct pvr_renderpass_context *ctx, input_subpass->color_count + input_subpass->input_count; VkResult result; + if (max_rts == 0) + return VK_SUCCESS; + hw_subpass->setup.mrt_resources = vk_zalloc(ctx->allocator, sizeof(hw_subpass->setup.mrt_resources[0U]) * max_rts, @@ -847,6 +850,9 @@ pvr_copy_storage_details(struct pvr_renderpass_context *ctx, hw_subpass->setup.num_render_targets = input_subpass->color_count; + if (input_subpass->input_count == 0) + return VK_SUCCESS; + /* For this subpass's input attachments. */ hw_subpass->input_access = vk_alloc(ctx->allocator, sizeof(hw_subpass->input_access[0U]) *