radv: check buffer size in vkCreateBuffer()
authorSamuel Iglesias Gonsálvez <siglesias@igalia.com>
Wed, 8 Apr 2020 08:55:37 +0000 (10:55 +0200)
committerMarge Bot <eric+marge@anholt.net>
Wed, 8 Apr 2020 11:03:35 +0000 (11:03 +0000)
Fixes:

   dEQP-VK.api.buffer.basic.size_max_uint64

Signed-off-by: Samuel Iglesias Gonsálvez <siglesias@igalia.com>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4487>

src/amd/vulkan/radv_device.c

index 00e3a7ca94780314e92ea2d483c56f6d737de8d9..fb81d782a148415cf65a89f172ebd78a73086905 100644 (file)
@@ -6237,6 +6237,9 @@ VkResult radv_CreateBuffer(
        RADV_FROM_HANDLE(radv_device, device, _device);
        struct radv_buffer *buffer;
 
+       if (pCreateInfo->size > RADV_MAX_MEMORY_ALLOCATION_SIZE)
+               return VK_ERROR_OUT_OF_DEVICE_MEMORY;
+
        assert(pCreateInfo->sType == VK_STRUCTURE_TYPE_BUFFER_CREATE_INFO);
 
        buffer = vk_alloc2(&device->alloc, pAllocator, sizeof(*buffer), 8,