[PATCH i-g-t 3/8] lib/igt_drm_clients: Fix leaks

Tvrtko Ursulin tursulin at ursulin.net
Wed Apr 3 16:09:19 UTC 2024


On 03/04/2024 16:39, Umesh Nerlige Ramappa wrote:
> On Tue, Apr 02, 2024 at 03:17:11PM -0700, Lucas De Marchi wrote:
>> Stop leaking memory-related fields.
>>
>> Signed-off-by: Lucas De Marchi <lucas.demarchi at intel.com>
>> ---
>> lib/igt_drm_clients.c | 10 ++++++++++
>> 1 file changed, 10 insertions(+)
>>
>> diff --git a/lib/igt_drm_clients.c b/lib/igt_drm_clients.c
>> index c8dc21d6a..c174c96ab 100644
>> --- a/lib/igt_drm_clients.c
>> +++ b/lib/igt_drm_clients.c
>> @@ -221,9 +221,19 @@ void igt_drm_client_free(struct igt_drm_client 
>> *c, bool clear)
>>         free(c->engines->names);
>>     }
>>     free(c->engines);
>> +
>>     free(c->val);
>>     free(c->last);
>>
>> +    if (c->regions) {
>> +        for (i = 0; i <= c->regions->max_region_id; i++)
>> +            free(c->regions->names[i]);
>> +        free(c->regions->names);
>> +    }
>> +    free(c->regions);
>> +
>> +    free(c->memory);
>> +
> 
> Looks correct as I don't see this being freed elsewhere.

I concur - good catch!

Regards,

Tvrtko

> Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa at intel.com>
> 
>>     if (clear)
>>         memset(c, 0, sizeof(*c));
>> }
>> -- 
>> 2.43.0
>>


More information about the igt-dev mailing list