All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <Alexander.Levin@microsoft.com>
To: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Cc: Yong Zhao <yong.zhao@amd.com>,
	Felix Kuehling <Felix.Kuehling@amd.com>,
	Oded Gabbay <oded.gabbay@gmail.com>,
	Sasha Levin <Alexander.Levin@microsoft.com>
Subject: [PATCH AUTOSEL for 4.14 68/84] drm/amdkfd: Fix memory leaks in kfd topology
Date: Sat, 3 Mar 2018 22:26:40 +0000	[thread overview]
Message-ID: <20180303222518.26271-68-alexander.levin@microsoft.com> (raw)
In-Reply-To: <20180303222518.26271-1-alexander.levin@microsoft.com>

From: Yong Zhao <yong.zhao@amd.com>

[ Upstream commit 5108d768408abc80e4e8d99f5b406a73cb04056b ]

Kobject created using kobject_create_and_add() can be freed using
kobject_put() when there is no referenece any more. However,
kobject memory allocated with kzalloc() has to set up a release
callback in order to free it when the counter decreases to 0.
Otherwise it causes memory leak.

Signed-off-by: Yong Zhao <yong.zhao@amd.com>
Signed-off-by: Felix Kuehling <Felix.Kuehling@amd.com>
Reviewed-by: Oded Gabbay <oded.gabbay@gmail.com>
Signed-off-by: Oded Gabbay <oded.gabbay@gmail.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_topology.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
index 19ce59028d6b..e0b78fd9804d 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_topology.c
@@ -501,11 +501,17 @@ static ssize_t sysprops_show(struct kobject *kobj, struct attribute *attr,
 	return ret;
 }
 
+static void kfd_topology_kobj_release(struct kobject *kobj)
+{
+	kfree(kobj);
+}
+
 static const struct sysfs_ops sysprops_ops = {
 	.show = sysprops_show,
 };
 
 static struct kobj_type sysprops_type = {
+	.release = kfd_topology_kobj_release,
 	.sysfs_ops = &sysprops_ops,
 };
 
@@ -541,6 +547,7 @@ static const struct sysfs_ops iolink_ops = {
 };
 
 static struct kobj_type iolink_type = {
+	.release = kfd_topology_kobj_release,
 	.sysfs_ops = &iolink_ops,
 };
 
@@ -568,6 +575,7 @@ static const struct sysfs_ops mem_ops = {
 };
 
 static struct kobj_type mem_type = {
+	.release = kfd_topology_kobj_release,
 	.sysfs_ops = &mem_ops,
 };
 
@@ -607,6 +615,7 @@ static const struct sysfs_ops cache_ops = {
 };
 
 static struct kobj_type cache_type = {
+	.release = kfd_topology_kobj_release,
 	.sysfs_ops = &cache_ops,
 };
 
@@ -729,6 +738,7 @@ static const struct sysfs_ops node_ops = {
 };
 
 static struct kobj_type node_type = {
+	.release = kfd_topology_kobj_release,
 	.sysfs_ops = &node_ops,
 };
 
-- 
2.14.1

  parent reply	other threads:[~2018-03-04  0:13 UTC|newest]

Thread overview: 84+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-03 22:26 [PATCH AUTOSEL for 4.14 01/84] drm/edid: set ELD connector type in drm_edid_to_eld() Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 03/84] video/hdmi: Allow "empty" HDMI infoframes Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 02/84] dma-buf/fence: Fix lock inversion within dma-fence-array Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 05/84] HID: elo: clear BTN_LEFT mapping Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 04/84] HID: multitouch: Only look at non touch fields in first packet of a frame Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 06/84] iwlwifi: mvm: rs: don't override the rate history in the search cycle Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 08/84] clk: meson: gxbb: fix wrong clock for SARADC/SANA Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 07/84] ARM: dts: koelsch: Move cec_clock to root node Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 09/84] ARM: dts: exynos: Correct Trats2 panel reset line Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 10/84] drm/amdgpu: fix get_max_engine_clock_in_mhz Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 12/84] typec: tcpm: fusb302: Resolve out of order messaging events Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 11/84] staging: rtl8822be: fix missing null check on dev_alloc_skb return Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 13/84] USB: ledtrig-usbport: fix of-node leak Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 15/84] sched: Stop resched_cpu() from sending IPIs to offline CPUs Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 14/84] sched: Stop switched_to_rt() " Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 17/84] crypto: cavium - fix memory leak on info Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 16/84] crypto: ecc - Fix NULL pointer deref. on no default_rng Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 18/84] test_firmware: fix setting old custom fw path back on exit Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 20/84] net: ieee802154: adf7242: Fix bug if defined DEBUG Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 19/84] ASoC: fsl_ssi: only enable proper channel slots in AC'97 mode Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 22/84] net: xfrm: allow clearing socket xfrm policies Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 21/84] rtc: brcmstb-waketimer: fix error handling in brcmstb_waketmr_probe() Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 23/84] mtd: nand: fix interpretation of NAND_CMD_NONE in nand_command[_lp]() Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 24/84] net: thunderx: Set max queue count taking XDP_TX into account Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 25/84] ARM: dts: am335x-pepper: Fix the audio CODEC's reset pin Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 26/84] ARM: dts: omap3-n900: " Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 27/84] mtd: nand: ifc: update bufnum mask for ver >= 2.0.0 Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 29/84] xfrm: Fix xfrm_replay_overflow_offload_esn Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 28/84] userns: Don't fail follow_automount based on s_user_ns Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 30/84] leds: pm8058: Silence pointer to integer size warning Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 31/84] clk: ti: clkctrl: add support for retrying failed init Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 32/84] ASoC: tlv320aic31xx: Handle inverted BCLK in non-DSP modes Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 34/84] power: supply: ab8500_charger: Bail out in case of error in 'ab8500_charger_init_hw_registers()' Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 33/84] power: supply: ab8500_charger: Fix an error handling path Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 36/84] iio: adc: ina2xx: Shift bus voltage register to mask flag bits Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 35/84] drm/etnaviv: make THERMAL selectable Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 37/84] iio: health: max30102: Add power enable parameter to get_temp function Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 38/84] ath10k: update tdls teardown state to target Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 39/84] cpufreq: Fix governor module removal race Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 40/84] dmaengine: bcm2835-dma: Use vchan_terminate_vdesc() instead of desc_free Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 41/84] dmaengine: amba-pl08x: " Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 42/84] drm/amdgpu:fix random missing of FLR NOTIFY Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 43/84] scsi: ses: don't ask for diagnostic pages repeatedly during probe Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 44/84] pwm: stmpe: Fix wrong register offset for hwpwm=2 case Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 45/84] drm/sun4i: Fix format mask in DE2 driver Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 46/84] pinctrl: sh-pfc: r8a7791: Add can_clk function Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 47/84] pinctrl: sh-pfc: r8a7795-es1: Fix MOD_SEL1 bit[25:24] to 0x3 when using STP_ISEN_1_D Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 48/84] perf annotate: Fix unnecessary memory allocation for s390x Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 49/84] perf annotate: Fix objdump comment parsing for Intel mov dissassembly Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 50/84] iwlwifi: mvm: avoid dumping assert log when device is stopped Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 51/84] drm/amdgpu:fix virtual dce bug Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 53/84] mwifiex: cfg80211: do not change virtual interface during scan processing Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 52/84] clk: qcom: msm8916: fix mnd_width for codec_digcodec Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 54/84] ath10k: fix invalid STS_CAP_OFFSET_MASK Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 56/84] spi: sun6i: disable/unprepare clocks on remove Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 55/84] tools/usbip: fixes build with musl libc toolchain Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 57/84] bnxt_en: Don't print "Link speed -1 no longer supported" messages Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 58/84] scsi: core: scsi_get_device_flags_keyed(): Always return device flags Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 59/84] scsi: devinfo: apply to HP XP the same flags as Hitachi VSP Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 61/84] media: vsp1: Prevent suspending and resuming DRM pipelines Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 60/84] scsi: dh: add new rdac devices Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 62/84] dm raid: fix raid set size revalidation Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 63/84] media: cpia2: Fix a couple off by one bugs Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 64/84] media: davinci: vpif_capture: add NULL check on devm_kzalloc return value Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 66/84] net: sched: drop qdisc_reset from dev_graft_qdisc Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 65/84] virtio_net: Disable interrupts if napi_complete_done rescheduled napi Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 67/84] veth: set peer GSO values Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 69/84] powerpc/modules: Don't try to restore r2 after a sibling call Sasha Levin
2018-03-03 22:26 ` Sasha Levin [this message]
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 70/84] powerpc/64: Don't trace irqs-off at interrupt return to soft-disabled context Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 71/84] arm64: dts: renesas: salvator-common: Add EthernetAVB PHY reset Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 72/84] agp/intel: Flush all chipset writes after updating the GGTT Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 74/84] mac80211: remove BUG() when interface type is invalid Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 73/84] mac80211_hwsim: enforce PS_MANUAL_POLL to be set after PS_ENABLED Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 75/84] crypto: caam/qi - use correct print specifier for size_t Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 76/84] ASoC: nuc900: Fix a loop timeout test Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 77/84] mmc: mmc_test: Ensure command queue is disabled for testing Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 78/84] Fix misannotated out-of-line _copy_to_user() Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 79/84] ipvlan: add L2 check for packets arriving via virtual devices Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 80/84] rcutorture/configinit: Fix build directory error message Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 81/84] locking/locktorture: Fix num reader/writer corner cases Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 82/84] ima: relax requiring a file signature for new files with zero length Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 83/84] IB/mlx5: revisit -Wmaybe-uninitialized warning Sasha Levin
2018-03-03 22:26 ` [PATCH AUTOSEL for 4.14 84/84] dmaengine: qcom_hidma: check pending interrupts 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=20180303222518.26271-68-alexander.levin@microsoft.com \
    --to=alexander.levin@microsoft.com \
    --cc=Felix.Kuehling@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oded.gabbay@gmail.com \
    --cc=stable@vger.kernel.org \
    --cc=yong.zhao@amd.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.