From 3b3df7b8a98c4171e402a7c4e7170b9d937aae09 Mon Sep 17 00:00:00 2001 From: Erik Faye-Lund Date: Mon, 22 Apr 2024 14:56:24 +0200 Subject: [PATCH] panvk: avoid dereferencing a null-pointer If we're passed a memory-info, but no memory-prop, we'd end up dereferencing a null-pointer here. Let's use a fallback struct instead, similar to what RADV does. Fixes: d970fe2e9d6 ("panfrost: Add a Vulkan driver for Midgard/Bifrost GPUs") CID: 1496060 Reviewed-by: Boris Brezillon Part-of: --- src/panfrost/vulkan/panvk_physical_device.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/panfrost/vulkan/panvk_physical_device.c b/src/panfrost/vulkan/panvk_physical_device.c index 4177419ea664e..fea213952fa91 100644 --- a/src/panfrost/vulkan/panvk_physical_device.c +++ b/src/panfrost/vulkan/panvk_physical_device.c @@ -1250,6 +1250,13 @@ panvk_GetPhysicalDeviceImageFormatProperties2( * present and VkExternalImageFormatProperties will be ignored. */ if (external_info && external_info->handleType != 0) { + VkExternalImageFormatProperties fallback_external_props; + + if (!external_props) { + memset(&fallback_external_props, 0, sizeof(fallback_external_props)); + external_props = &fallback_external_props; + } + result = panvk_get_external_image_format_properties( physical_device, base_info, external_info->handleType, &external_props->externalMemoryProperties);