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

Edward O'Callaghan funfunctor at folklore1984.net
Tue Oct 11 11:08:47 UTC 2016



On 10/11/2016 10:04 PM, Emil Velikov wrote:
> 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.

Good idea, I'll look into it now thanks for the suggestion.

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

Alright.

> 
> -Emil
> 

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: OpenPGP digital signature
URL: <https://lists.freedesktop.org/archives/mesa-dev/attachments/20161011/58989dae/attachment.sig>


More information about the mesa-dev mailing list