aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorBernard Zhao <bernard@vivo.com>2020-06-20 17:11:52 +0800
committerAlex Deucher <alexander.deucher@amd.com>2020-07-01 01:59:26 -0400
commitdc2f832ecb045dd43793531ae149e1767696f5ad (patch)
tree45b5267655b057b730b0335c059dc243cfb260ce
parentdrm/radeon: fix fb_div check in ni_init_smc_spll_table() (diff)
downloadwireguard-linux-dc2f832ecb045dd43793531ae149e1767696f5ad.tar.xz
wireguard-linux-dc2f832ecb045dd43793531ae149e1767696f5ad.zip
drm/amd: fix potential memleak in err branch
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 <bernard@vivo.com> Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com> Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
-rw-r--r--drivers/gpu/drm/amd/amdkfd/kfd_process.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_process.c b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
index 8616a204e4c3..d0409df35032 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_process.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_process.c
@@ -539,6 +539,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;
}