From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Qiushi Wu <wu000273@umn.edu>,
Felix Kuehling <Felix.Kuehling@amd.com>,
Alex Deucher <alexander.deucher@amd.com>,
Sasha Levin <sashal@kernel.org>,
amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Subject: [PATCH AUTOSEL 4.19 12/38] drm/amdkfd: Fix reference count leaks.
Date: Fri, 21 Aug 2020 12:17:41 -0400 [thread overview]
Message-ID: <20200821161807.348600-12-sashal@kernel.org> (raw)
In-Reply-To: <20200821161807.348600-1-sashal@kernel.org>
From: Qiushi Wu <wu000273@umn.edu>
[ Upstream commit 20eca0123a35305e38b344d571cf32768854168c ]
kobject_init_and_add() takes reference even when it fails.
If this function returns an error, kobject_put() must be called to
properly clean up the memory associated with the object.
Signed-off-by: Qiushi Wu <wu000273@umn.edu>
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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 20 +++++++++++++++-----
1 file changed, 15 insertions(+), 5 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
index 0805c423a5ce0..5cf499a07806a 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
@@ -592,8 +592,10 @@ static int kfd_build_sysfs_node_entry(struct kfd_topology_device *dev,
ret = kobject_init_and_add(dev->kobj_node, &node_type,
sys_props.kobj_nodes, "%d", id);
- if (ret < 0)
+ if (ret < 0) {
+ kobject_put(dev->kobj_node);
return ret;
+ }
dev->kobj_mem = kobject_create_and_add("mem_banks", dev->kobj_node);
if (!dev->kobj_mem)
@@ -640,8 +642,10 @@ static int kfd_build_sysfs_node_entry(struct kfd_topology_device *dev,
return -ENOMEM;
ret = kobject_init_and_add(mem->kobj, &mem_type,
dev->kobj_mem, "%d", i);
- if (ret < 0)
+ if (ret < 0) {
+ kobject_put(mem->kobj);
return ret;
+ }
mem->attr.name = "properties";
mem->attr.mode = KFD_SYSFS_FILE_MODE;
@@ -659,8 +663,10 @@ static int kfd_build_sysfs_node_entry(struct kfd_topology_device *dev,
return -ENOMEM;
ret = kobject_init_and_add(cache->kobj, &cache_type,
dev->kobj_cache, "%d", i);
- if (ret < 0)
+ if (ret < 0) {
+ kobject_put(cache->kobj);
return ret;
+ }
cache->attr.name = "properties";
cache->attr.mode = KFD_SYSFS_FILE_MODE;
@@ -678,8 +684,10 @@ static int kfd_build_sysfs_node_entry(struct kfd_topology_device *dev,
return -ENOMEM;
ret = kobject_init_and_add(iolink->kobj, &iolink_type,
dev->kobj_iolink, "%d", i);
- if (ret < 0)
+ if (ret < 0) {
+ kobject_put(iolink->kobj);
return ret;
+ }
iolink->attr.name = "properties";
iolink->attr.mode = KFD_SYSFS_FILE_MODE;
@@ -759,8 +767,10 @@ static int kfd_topology_update_sysfs(void)
ret = kobject_init_and_add(sys_props.kobj_topology,
&sysprops_type, &kfd_device->kobj,
"topology");
- if (ret < 0)
+ if (ret < 0) {
+ kobject_put(sys_props.kobj_topology);
return ret;
+ }
sys_props.kobj_nodes = kobject_create_and_add("nodes",
sys_props.kobj_topology);
--
2.25.1
next prev parent reply other threads:[~2020-08-21 16:22 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-21 16:17 [PATCH AUTOSEL 4.19 01/38] ALSA: pci: delete repeated words in comments Sasha Levin
2020-08-21 16:17 ` [PATCH AUTOSEL 4.19 02/38] ASoC: img: Fix a reference count leak in img_i2s_in_set_fmt Sasha Levin
2020-08-21 16:17 ` [PATCH AUTOSEL 4.19 03/38] ASoC: img-parallel-out: Fix a reference count leak Sasha Levin
2020-08-21 16:17 ` [PATCH AUTOSEL 4.19 04/38] ASoC: tegra: Fix reference count leaks Sasha Levin
2020-08-21 16:17 ` [PATCH AUTOSEL 4.19 05/38] mfd: intel-lpss: Add Intel Emmitsburg PCH PCI IDs Sasha Levin
2020-08-21 16:17 ` [PATCH AUTOSEL 4.19 06/38] arm64: dts: qcom: msm8916: Pull down PDM GPIOs during sleep Sasha Levin
2020-08-21 16:17 ` [PATCH AUTOSEL 4.19 07/38] powerpc/xive: Ignore kmemleak false positives Sasha Levin
2020-08-21 16:17 ` [PATCH AUTOSEL 4.19 08/38] media: pci: ttpci: av7110: fix possible buffer overflow caused by bad DMA value in debiirq() Sasha Levin
2020-08-29 12:10 ` Pavel Machek
2020-08-29 17:16 ` Laurent Pinchart
2020-08-29 21:24 ` Sean Young
2020-08-30 7:33 ` Jia-Ju Bai
2020-08-30 22:25 ` Laurent Pinchart
2020-08-31 13:45 ` Jia-Ju Bai
2020-08-31 13:55 ` Laurent Pinchart
2020-08-30 7:24 ` Jia-Ju Bai
2020-08-21 16:17 ` [PATCH AUTOSEL 4.19 09/38] blktrace: ensure our debugfs dir exists Sasha Levin
2020-08-21 16:17 ` [PATCH AUTOSEL 4.19 10/38] scsi: target: tcmu: Fix crash on ARM during cmd completion Sasha Levin
2020-08-21 16:17 ` [PATCH AUTOSEL 4.19 11/38] iommu/iova: Don't BUG on invalid PFNs Sasha Levin
2020-08-21 16:17 ` Sasha Levin [this message]
2020-08-21 16:17 ` [PATCH AUTOSEL 4.19 13/38] drm/radeon: fix multiple reference count leak Sasha Levin
2020-08-21 16:17 ` [PATCH AUTOSEL 4.19 14/38] drm/amdgpu: fix ref count leak in amdgpu_driver_open_kms Sasha Levin
2020-08-21 16:17 ` [PATCH AUTOSEL 4.19 15/38] drm/amd/display: fix ref count leak in amdgpu_drm_ioctl Sasha Levin
2020-08-21 16:17 ` [PATCH AUTOSEL 4.19 16/38] drm/amdgpu: fix ref count leak in amdgpu_display_crtc_set_config Sasha Levin
2020-08-21 16:17 ` [PATCH AUTOSEL 4.19 17/38] drm/amdgpu/display: fix ref count leak when pm_runtime_get_sync fails Sasha Levin
2020-08-21 16:17 ` [PATCH AUTOSEL 4.19 18/38] scsi: lpfc: Fix shost refcount mismatch when deleting vport Sasha Levin
2020-08-21 16:17 ` [PATCH AUTOSEL 4.19 19/38] xfs: Don't allow logging of XFS_ISTALE inodes Sasha Levin
2020-08-21 16:17 ` [PATCH AUTOSEL 4.19 20/38] selftests/powerpc: Purge extra count_pmc() calls of ebb selftests Sasha Levin
2020-08-21 16:17 ` [PATCH AUTOSEL 4.19 21/38] f2fs: fix error path in do_recover_data() Sasha Levin
2020-08-21 16:17 ` [PATCH AUTOSEL 4.19 22/38] omapfb: fix multiple reference count leaks due to pm_runtime_get_sync Sasha Levin
2020-08-21 16:17 ` [PATCH AUTOSEL 4.19 23/38] PCI: Fix pci_create_slot() reference count leak Sasha Levin
2020-08-21 16:17 ` [PATCH AUTOSEL 4.19 24/38] ARM: dts: ls1021a: output PPS signal on FIPER2 Sasha Levin
2020-08-21 16:17 ` [PATCH AUTOSEL 4.19 25/38] rtlwifi: rtl8192cu: Prevent leaking urb Sasha Levin
2020-08-21 16:17 ` [PATCH AUTOSEL 4.19 26/38] mips/vdso: Fix resource leaks in genvdso.c Sasha Levin
2020-08-21 16:17 ` [PATCH AUTOSEL 4.19 27/38] cec-api: prevent leaking memory through hole in structure Sasha Levin
2020-08-21 16:17 ` [PATCH AUTOSEL 4.19 28/38] HID: quirks: add NOGET quirk for Logitech GROUP Sasha Levin
2020-08-21 16:17 ` [PATCH AUTOSEL 4.19 29/38] f2fs: fix use-after-free issue Sasha Levin
2020-08-21 16:17 ` [PATCH AUTOSEL 4.19 30/38] drm/nouveau/drm/noveau: fix reference count leak in nouveau_fbcon_open Sasha Levin
2020-08-21 16:18 ` [PATCH AUTOSEL 4.19 31/38] drm/nouveau: fix reference count leak in nv50_disp_atomic_commit Sasha Levin
2020-08-21 16:18 ` [PATCH AUTOSEL 4.19 32/38] drm/nouveau: Fix reference count leak in nouveau_connector_detect Sasha Levin
2020-08-21 16:18 ` [PATCH AUTOSEL 4.19 33/38] locking/lockdep: Fix overflow in presentation of average lock-time Sasha Levin
2020-08-21 16:18 ` [PATCH AUTOSEL 4.19 34/38] btrfs: file: reserve qgroup space after the hole punch range is locked Sasha Levin
2020-08-29 12:11 ` Pavel Machek
2020-08-30 14:46 ` Sasha Levin
2020-08-21 16:18 ` [PATCH AUTOSEL 4.19 35/38] scsi: iscsi: Do not put host in iscsi_set_flashnode_param() Sasha Levin
2020-08-21 16:18 ` [PATCH AUTOSEL 4.19 36/38] ceph: fix potential mdsc use-after-free crash Sasha Levin
2020-08-21 16:18 ` [PATCH AUTOSEL 4.19 37/38] scsi: fcoe: Memory leak fix in fcoe_sysfs_fcf_del() Sasha Levin
2020-08-21 16:18 ` [PATCH AUTOSEL 4.19 38/38] EDAC/ie31200: Fallback if host bridge device is already initialized Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20200821161807.348600-12-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=Felix.Kuehling@amd.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=wu000273@umn.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).