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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxx>
---
  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;
  	}
  }



[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux