summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYiwei Zhang <zzyiwei@chromium.org>2023-06-14 13:15:32 -0700
committerYiwei Zhang <zzyiwei@chromium.org>2023-06-14 13:15:32 -0700
commit144da8655228944a6b3f5e7c6ae49c4119bb6699 (patch)
treea45f18872d441413fa11b2b89eb3e1c6e67b6515
parentf8f1b43b201a55b0a3db576d74b44d45d1b13d07 (diff)
vkr: validate memoryTypeIndex
Signed-off-by: Yiwei Zhang <zzyiwei@chromium.org> Part-of: <https://gitlab.freedesktop.org/virgl/virglrenderer/-/merge_requests/1161>
-rw-r--r--src/venus/vkr_device_memory.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/venus/vkr_device_memory.c b/src/venus/vkr_device_memory.c
index 80e896a..c2a3a23 100644
--- a/src/venus/vkr_device_memory.c
+++ b/src/venus/vkr_device_memory.c
@@ -115,6 +115,11 @@ vkr_dispatch_vkAllocateMemory(struct vn_dispatch_context *dispatch,
!(export_info->handleTypes & VK_EXTERNAL_MEMORY_HANDLE_TYPE_DMA_BUF_BIT_EXT);
struct vkr_device_memory *mem = NULL;
const uint32_t mem_type_index = args->pAllocateInfo->memoryTypeIndex;
+ if (mem_type_index >= physical_dev->memory_properties.memoryTypeCount) {
+ args->ret = VK_ERROR_UNKNOWN;
+ return;
+ }
+
const uint32_t property_flags =
physical_dev->memory_properties.memoryTypes[mem_type_index].propertyFlags;
uint32_t valid_fd_types = 0;