[Mesa-dev] [PATCH] radv: Fix mem leak in 'radv_physical_device_init()' fail path

Edward O'Callaghan funfunctor at folklore1984.net
Tue Oct 11 09:50:54 UTC 2016


The call to 'radv_amdgpu_winsys_create()' does a heap
allocation and expects the call site to free it, however the
fail path for 'radv_init_wsi()' fails to to do so.

Signed-off-by: Edward O'Callaghan <funfunctor at folklore1984.net>
---
 src/amd/vulkan/radv_device.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/amd/vulkan/radv_device.c b/src/amd/vulkan/radv_device.c
index 8c59344..f461ce1 100644
--- a/src/amd/vulkan/radv_device.c
+++ b/src/amd/vulkan/radv_device.c
@@ -74,8 +74,11 @@ radv_physical_device_init(struct radv_physical_device *device,
 	}
 	device->ws->query_info(device->ws, &device->rad_info);
 	result = radv_init_wsi(device);
-	if (result != VK_SUCCESS)
+	if (result != VK_SUCCESS) {
+		free(device->ws);
+		device->ws = NULL;
 		goto fail;
+	}
 
 	fprintf(stderr, "WARNING: radv is not a conformant vulkan implementation, testing use only.\n");
 	device->name = device->rad_info.name;
-- 
2.7.4



More information about the mesa-dev mailing list