vulkan/wsi: Don't leak the FD when GetImageDrmFormatModifierProperties fails

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>
(cherry picked from commit 34d2637fa7)
This commit is contained in:
Jason Ekstrand 2020-03-02 17:05:59 -06:00 committed by Eric Engestrom
parent 4fa692872b
commit 7daa262486
2 changed files with 4 additions and 2 deletions

View file

@ -31,7 +31,7 @@
"description": "vulkan/wsi: Don't leak the FD when GetImageDrmFormatModifierProperties fails",
"nominated": true,
"nomination_type": 0,
"resolution": 0,
"resolution": 1,
"master_sha": null,
"because_sha": null
},

View 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);