Mesa (master): radv: fix a memleak if the physical device initialization failed

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed May 6 06:55:55 UTC 2020


Module: Mesa
Branch: master
Commit: 9c62e63aca202bef07b20441618dd360b94b2f7d
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=9c62e63aca202bef07b20441618dd360b94b2f7d

Author: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Date:   Wed Apr 29 14:03:24 2020 +0200

radv: fix a memleak if the physical device initialization failed

The disk cache object should be freed.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Reviewed-by: Bas Nieuwenhuizen <bas at basnieuwenhuizen.nl>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4806>

---

 src/amd/vulkan/radv_device.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index 118f8f2b32a..638fe0325ac 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -297,7 +297,7 @@ radv_physical_device_init(struct radv_physical_device *device,
 
 	if (!device->ws) {
 		result = vk_error(instance, VK_ERROR_INCOMPATIBLE_DRIVER);
-		goto fail;
+		goto fail_fd;
 	}
 
 	if (drm_device && instance->enabled_extensions.KHR_display) {
@@ -328,10 +328,9 @@ radv_physical_device_init(struct radv_physical_device *device,
 		 device->rad_info.name);
 
 	if (radv_device_get_cache_uuid(device->rad_info.family, device->cache_uuid)) {
-		device->ws->destroy(device->ws);
 		result = vk_errorf(instance, VK_ERROR_INITIALIZATION_FAILED,
 				   "cannot generate UUID");
-		goto fail;
+		goto fail_wsi;
 	}
 
 	/* These flags affect shader compilation. */
@@ -399,14 +398,17 @@ radv_physical_device_init(struct radv_physical_device *device,
 	 */
 	result = radv_init_wsi(device);
 	if (result != VK_SUCCESS) {
-		device->ws->destroy(device->ws);
 		vk_error(instance, result);
-		goto fail;
+		goto fail_disk_cache;
 	}
 
 	return VK_SUCCESS;
 
-fail:
+fail_disk_cache:
+	disk_cache_destroy(device->disk_cache);
+fail_wsi:
+	device->ws->destroy(device->ws);
+fail_fd:
 	close(fd);
 	if (master_fd != -1)
 		close(master_fd);



More information about the mesa-commit mailing list