]> Git Repo - linux.git/commitdiff
drm/amd: fix potential memleak in err branch
authorBernard Zhao <[email protected]>
Sat, 20 Jun 2020 09:11:52 +0000 (17:11 +0800)
committerAlex Deucher <[email protected]>
Wed, 24 Jun 2020 22:03:16 +0000 (18:03 -0400)
The function kobject_init_and_add alloc memory like:
kobject_init_and_add->kobject_add_varg->kobject_set_name_vargs
->kvasprintf_const->kstrdup_const->kstrdup->kmalloc_track_caller
->kmalloc_slab, in err branch this memory not free. If use
kmemleak, this path maybe catched.
These changes are to add kobject_put in kobject_init_and_add
failed branch, fix potential memleak.

Signed-off-by: Bernard Zhao <[email protected]>
Reviewed-by: Felix Kuehling <[email protected]>
Signed-off-by: Felix Kuehling <[email protected]>
Signed-off-by: Alex Deucher <[email protected]>
Cc: [email protected]
drivers/gpu/drm/amd/amdkfd/kfd_process.c

index d27221ddcdeb3d920021431ad37a542a3a85ecea..0e0c42e9f6a3153ccbdf44dd0a0028a4fa81f767 100644 (file)
@@ -428,6 +428,7 @@ struct kfd_process *kfd_create_process(struct file *filep)
                                           (int)process->lead_thread->pid);
                if (ret) {
                        pr_warn("Creating procfs pid directory failed");
+                       kobject_put(process->kobj);
                        goto out;
                }
 
This page took 0.057237 seconds and 4 git commands to generate.