From 3c6a02157b0ffc7fee88280af1d05fb1d36459d2 Mon Sep 17 00:00:00 2001 From: Mauro Rossi Date: Fri, 27 Jul 2018 20:13:21 +0200 Subject: [PATCH] HACK: radv/image: avoid pAllocator null pointer dereference (v2) Inspired by anv code, pAllocator is not always directly available (v1) use RADV_FROM_HANDLE() to map device onto device_ and evaluate: pAllocator ? pAllocator : &device_->alloc; This attempt was still affected by segfaults for the null pointer dereference (v2) use RADV_FROM_HANDLE() to map device onto device_ and evaluate: pAllocator = &device_->alloc; The latter empirically avoids radv segfault in both 3DMARK API Overhead and 3DMARK Slingshot Extreme. --- src/amd/vulkan/radv_image.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/amd/vulkan/radv_image.c b/src/amd/vulkan/radv_image.c index 826f898d28..8dfd3f5ff1 100644 --- a/src/amd/vulkan/radv_image.c +++ b/src/amd/vulkan/radv_image.c @@ -1245,6 +1245,8 @@ radv_CreateImage(VkDevice device, const VkAllocationCallbacks *pAllocator, VkImage *pImage) { + RADV_FROM_HANDLE(radv_device, device_, device); + pAllocator = &device_->alloc; #ifdef ANDROID const VkNativeBufferANDROID *gralloc_info = vk_find_struct_const(pCreateInfo->pNext, NATIVE_BUFFER_ANDROID); -- 2.17.1