[PATCH v1 1/1] kfd: fixed memleak about release topology
Felix Kuehling
felix.kuehling at amd.com
Wed Aug 17 22:31:19 UTC 2022
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?
Regards,
Felix
> sys_props.kobj_topology = NULL;
> }
> }
More information about the dri-devel
mailing list