vulkan: Fix memory leaks.
authorVinson Lee <vlee@freedesktop.org>
Mon, 31 Aug 2020 00:39:43 +0000 (17:39 -0700)
committerMarge Bot <eric+marge@anholt.net>
Tue, 1 Sep 2020 00:47:19 +0000 (00:47 +0000)
Fix warnings reported by Coverity Scan.

Resource leak (RESOURCE_LEAK)
leaked_storage: Variable info going out of scope leaks the storage it
points to.

Fixes: 9bc5b2d169d3 ("vulkan: add initial device selection layer. (v6.1)")
Signed-off-by: Vinson Lee <vlee@freedesktop.org>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6509>

src/vulkan/device-select-layer/device_select_layer.c

index 7bec8890344c3122cf12d94ba7b00b71fb43a5f4..3a5981063c861e9f70b8b1c5efe98e24ae18f226 100644 (file)
@@ -137,14 +137,17 @@ static VkResult device_select_CreateInstance(const VkInstanceCreateInfo *pCreate
    PFN_vkCreateInstance fpCreateInstance =
       (PFN_vkCreateInstance)info->GetInstanceProcAddr(NULL, "vkCreateInstance");
    if (fpCreateInstance == NULL) {
+      free(info);
       return VK_ERROR_INITIALIZATION_FAILED;
    }
 
    chain_info->u.pLayerInfo = chain_info->u.pLayerInfo->pNext;
 
    VkResult result = fpCreateInstance(pCreateInfo, pAllocator, pInstance);
-   if (result != VK_SUCCESS)
+   if (result != VK_SUCCESS) {
+      free(info);
       return result;
+   }
 
    for (unsigned i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
       if (!strcmp(pCreateInfo->ppEnabledExtensionNames[i], VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME))