[PATCH v1 1/1] kfd: fixed memleak about release topology

ZhiJie.Zhang botton_zhang at 163.com
Fri Aug 19 03:18:50 UTC 2022



在 2022/8/18 6:31, Felix Kuehling 写道:
> Am 2022-07-15 um 04:07 schrieb ZhiJie.zhang:
>> memleak will happend that reload module due to ignore kfree when 
>> release topology
>>
>> Signed-off-by: ZhiJie.zhang <botton_zhang at 163.com>
>> ---
>>   drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c 
>> b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
>> index 8d50d207cf66..8b86f56bd50c 100644
>> --- a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
>> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
>> @@ -872,6 +872,7 @@ static void kfd_topology_release_sysfs(void)
>>           }
>>           kobject_del(sys_props.kobj_topology);
>>           kobject_put(sys_props.kobj_topology);
>> +        kfree(sys_props.kobj_topology);
> 
> Sorry for the late response. This looks incorrect. kobjects are 
> reference counted. The underlying memory should be freed by a callback 
> when the reference count reaches 0 in kobject_put. Freeing the object 
> here explicitly would lead to a double-free.
> 
> The callback in this case is kfd_topology_kobj_release, which calls 
> kfree. Am I missing anything?
> 
Yes, Your are right, this is my misstake, please ignore this patch
> Regards,
>    Felix
> 
> 
>>           sys_props.kobj_topology = NULL;
>>       }
>>   }

Regards.
Zhijie



More information about the dri-devel mailing list