drm/amd: fix potential memleak in err branch
authorBernard Zhao <bernard@vivo.com>
Sat, 20 Jun 2020 09:11:52 +0000 (17:11 +0800)
committerSasha Levin <sashal@kernel.org>
Tue, 30 Jun 2020 19:37:10 +0000 (15:37 -0400)
commit176a3c488476d077114d54810e221634aff94659
tree1218b65e44fc4c6be9e2d1566abb0299bedd970e
parent0b3cc973f16fab7507297eaec1c0c262020b08c9
drm/amd: fix potential memleak in err branch

commit b5b78a6c8d8cb9c307bc6b16a754603424459d6e upstream.

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>
Cc: stable@vger.kernel.org
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/gpu/drm/amd/amdkfd/kfd_process.c