vulkan/wsi: Don't leak the FD when GetImageDrmFormatModifierProperties fails
authorJason Ekstrand <jason@jlekstrand.net>
Mon, 2 Mar 2020 23:05:59 +0000 (17:05 -0600)
committerMarge Bot <eric+marge@anholt.net>
Tue, 10 Mar 2020 16:39:27 +0000 (16:39 +0000)
Cc: mesa-stable@lists.freedesktop.org
Reviewed-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4135>

src/vulkan/wsi/wsi_common.c

index 0adf54eab8f3a46e6e8a255b9ee1f44f8501a50e..c278d5d13472ba1ce6e2324bcc3053e0f292ed14 100644 (file)
@@ -588,8 +588,10 @@ wsi_create_native_image(const struct wsi_swapchain *chain,
       result = wsi->GetImageDrmFormatModifierPropertiesEXT(chain->device,
                                                            image->image,
                                                            &image_mod_props);
-      if (result != VK_SUCCESS)
+      if (result != VK_SUCCESS) {
+         close(fd);
          goto fail;
+      }
       image->drm_modifier = image_mod_props.drmFormatModifier;
       assert(image->drm_modifier != DRM_FORMAT_MOD_INVALID);