Skip to contentSkip to conversation

drm/amdkfd: fix memleak in kfd_procfs_add_sysfs_stats

PATCH New 董泽春 1 participant 1 message May 29

Subsystems (3)
lore
Share & tools
lore

董泽春

author
#0 lore raw

PATCH 1/1 drm/amdkfd: fix memleak in kfd_procfs_add_sysfs_stats

From a87d5d2f02849231ac1636374d1b466e466db147 Mon Sep 17 00:00:00 2001

From: Zechun Dong <[email protected]>
Date: Thu, 28 May 2026 17:50:23 +0800
Subject: [PATCH] drm/amdkfd: fix memleak in kfd_procfs_add_sysfs_stats

When kfd_lookup_process_by_mm fails for a non-primary context, the process->kobj allocated earlier in the function is not freed. Add the missing cleanup.

---
 drivers/gpu/drm/amd/amdkfd/kfd_process.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_process.c +4 -1
index d28ca581cad0..4a47d3535cae 100644
@@ -847,8 +847,11 @@ int kfd_create_process_sysfs(struct kfd_process *process)
                                           (int)process->lead_thread->pid);
        else {
                primary_process = kfd_lookup_process_by_mm(process->lead_thread->mm);
- if (!primary_process)
+ if (!primary_process) {
+ kobject_put(process->kobj);
+ process->kobj = NULL;
                        return -ESRCH;
+ }
 
 
                ret = kobject_init_and_add(process->kobj, &procfs_type,
                                           primary_process->kobj, "context_%u",
Signature · 10 lines
2.43.0
|
|


|
|


|