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 <Karmjit.Mahil@imgtec.com>
Reviewed-by: Frank Binns <frank.binns@imgtec.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23070>
This commit is contained in:
Karmjit Mahil 2023-05-05 14:06:02 +01:00 committed by Marge Bot
parent 5f60444b13
commit 792cf1caff

View file

@ -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]) *