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

Emil Velikov emil.l.velikov at gmail.com
Tue Oct 11 11:04:45 UTC 2016


On 11 October 2016 at 10:50, Edward O'Callaghan
<funfunctor at folklore1984.net> wrote:
> 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);
You need a proper API to teardown the winsys which complements
radv_amdgpu_winsys_create. As-is you're papering over the problem.

Furthermore the device contents should not be modified if the
{anv,radv}_physical_device_init function fails.

-Emil


More information about the mesa-dev mailing list