linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org, Namhyung Kim <namhyung@kernel.org>,
	Jiri Olsa <jolsa@redhat.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Andi Kleen <ak@linux.intel.com>, Ian Rogers <irogers@google.com>,
	John Garry <john.garry@huawei.com>,
	Kajol Jain <kjain@linux.ibm.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Stephane Eranian <eranian@google.com>,
	Arnaldo Carvalho de Melo <acme@redhat.com>,
	Sasha Levin <sashal@kernel.org>
Subject: [PATCH 5.8 060/118] perf metric: Fix some memory leaks
Date: Mon, 21 Sep 2020 18:27:52 +0200	[thread overview]
Message-ID: <20200921162039.141888218@linuxfoundation.org> (raw)
In-Reply-To: <20200921162036.324813383@linuxfoundation.org>

From: Namhyung Kim <namhyung@kernel.org>

[ Upstream commit 4f57a1ed749a81ec553d89233cab53db9365e193 ]

I found some memory leaks while reading the metric code.  Some are real
and others only occur in the error path.  When it failed during metric
or event parsing, it should release all resources properly.

Fixes: b18f3e365019d ("perf stat: Support JSON metrics in perf stat")
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Jiri Olsa <jolsa@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: John Garry <john.garry@huawei.com>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lore.kernel.org/lkml/20200915031819.386559-2-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 tools/perf/util/metricgroup.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/metricgroup.c b/tools/perf/util/metricgroup.c
index 9e21aa767e417..344a75718afc3 100644
--- a/tools/perf/util/metricgroup.c
+++ b/tools/perf/util/metricgroup.c
@@ -443,6 +443,9 @@ void metricgroup__print(bool metrics, bool metricgroups, char *filter,
 						continue;
 					strlist__add(me->metrics, s);
 				}
+
+				if (!raw)
+					free(s);
 			}
 			free(omg);
 		}
@@ -726,7 +729,7 @@ int metricgroup__parse_groups(const struct option *opt,
 	ret = metricgroup__add_metric_list(str, metric_no_group,
 					   &extra_events, &group_list);
 	if (ret)
-		return ret;
+		goto out;
 	pr_debug("adding %s\n", extra_events.buf);
 	bzero(&parse_error, sizeof(parse_error));
 	ret = parse_events(perf_evlist, extra_events.buf, &parse_error);
@@ -734,11 +737,11 @@ int metricgroup__parse_groups(const struct option *opt,
 		parse_events_print_error(&parse_error, extra_events.buf);
 		goto out;
 	}
-	strbuf_release(&extra_events);
 	ret = metricgroup__setup_events(&group_list, metric_no_merge,
 					perf_evlist, metric_events);
 out:
 	metricgroup__free_egroups(&group_list);
+	strbuf_release(&extra_events);
 	return ret;
 }
 
-- 
2.25.1




  parent reply	other threads:[~2020-09-21 16:46 UTC|newest]

Thread overview: 125+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-21 16:26 [PATCH 5.8 000/118] 5.8.11-rc1 review Greg Kroah-Hartman
2020-09-21 16:26 ` [PATCH 5.8 001/118] RDMA/bnxt_re: Restrict the max_gids to 256 Greg Kroah-Hartman
2020-09-21 16:26 ` [PATCH 5.8 002/118] dt-bindings: spi: Fix spi-bcm-qspi compatible ordering Greg Kroah-Hartman
2020-09-21 16:26 ` [PATCH 5.8 003/118] mptcp: sendmsg: reset iter on error Greg Kroah-Hartman
2020-09-21 16:26 ` [PATCH 5.8 004/118] net: handle the return value of pskb_carve_frag_list() correctly Greg Kroah-Hartman
2020-09-21 16:26 ` [PATCH 5.8 005/118] dt-bindings: PCI: intel,lgm-pcie: Fix matching on all snps,dw-pcie instances Greg Kroah-Hartman
2020-09-21 16:26 ` [PATCH 5.8 006/118] hv_netvsc: Remove "unlikely" from netvsc_select_queue Greg Kroah-Hartman
2020-09-21 16:26 ` [PATCH 5.8 007/118] loop: Set correct device size when using LOOP_CONFIGURE Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 008/118] firmware_loader: fix memory leak for paged buffer Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 009/118] xprtrdma: Release in-flight MRs on disconnect Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 010/118] NFSv4.1 handle ERR_DELAY error reclaiming locking state on delegation recall Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 011/118] phy: omap-usb2-phy: disable PHY charger detect Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 012/118] habanalabs: prevent user buff overflow Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 013/118] habanalabs: fix report of RAZWI initiator coordinates Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 014/118] scsi: pm8001: Fix memleak in pm8001_exec_internal_task_abort Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 015/118] scsi: libfc: Fix for double free() Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 016/118] scsi: lpfc: Fix FLOGI/PLOGI receive race condition in pt2pt discovery Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 017/118] scsi: lpfc: Extend the RDF FPIN Registration descriptor for additional events Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 018/118] regulator: pwm: Fix machine constraints application Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 019/118] spi: spi-loopback-test: Fix out-of-bounds read Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 020/118] interconnect: Show bandwidth for disabled paths as zero in debugfs Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 021/118] NFS: Zero-stateid SETATTR should first return delegation Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 022/118] SUNRPC: stop printk reading past end of string Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 023/118] rapidio: Replace select DMAENGINES with depends on Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 024/118] cifs: fix DFS mount with cifsacl/modefromsid Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 025/118] openrisc: Fix cache API compile issue when not inlining Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 026/118] nvme-fc: cancel async events before freeing event struct Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 027/118] nvme-rdma: " Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 028/118] nvme-tcp: " Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 029/118] block: only call sched requeue_request() for scheduled requests Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 030/118] f2fs: fix indefinite loop scanning for free nid Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 031/118] f2fs: Return EOF on unaligned end of file DIO read Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 032/118] i2c: algo: pca: Reapply i2c bus settings after reset Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 033/118] spi: Fix memory leak on splited transfers Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 034/118] KVM: Check the allocation of pv cpu mask Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 035/118] KVM: MIPS: Change the definition of kvm type Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 036/118] clk: davinci: Use the correct size when allocating memory Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 037/118] clk: rockchip: Fix initialization of mux_pll_src_4plls_p Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 038/118] ASoC: Intel: skl_hda_dsp_generic: Fix NULLptr dereference in autosuspend delay Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 039/118] ASoC: qcom: Set card->owner to avoid warnings Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 040/118] ASoC: rt1308-sdw: Fix return check for devm_regmap_init_sdw() Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 041/118] ASoC: rt711: " Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 042/118] ASoC: rt715: " Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 043/118] ASoC: rt700: " Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 044/118] ASoC: qcom: common: Fix refcount imbalance on error Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 045/118] drm/mediatek: dsi: Fix scrolling of panel with small hfp or hbp Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 046/118] powerpc/book3s64/radix: Fix boot failure with large amount of guest memory Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 047/118] ASoC: soc-core: add snd_soc_find_dai_with_mutex() Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 048/118] ASoC: meson: axg-toddr: fix channel order on g12 platforms Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 049/118] ASoC: tlv320adcx140: Fix accessing uninitialized adcx140->dev Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 050/118] ASoC: Intel: haswell: Fix power transition refactor Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 051/118] ASoC: core: Do not cleanup uninitialized dais on soc_pcm_open failure Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 052/118] Drivers: hv: vmbus: hibernation: do not hang forever in vmbus_bus_resume() Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 053/118] scsi: libsas: Fix error path in sas_notify_lldd_dev_found() Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 054/118] arm64: Allow CPUs unffected by ARM erratum 1418040 to come in late Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 055/118] Drivers: hv: vmbus: Add timeout to vmbus_wait_for_unload Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 056/118] perf test: Fix the "signal" test inline assembly Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 057/118] perf record: Dont clear events period if set by a term Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 058/118] MIPS: SNI: Fix MIPS_L1_CACHE_SHIFT Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 059/118] perf test: Free aliases for PMU event map aliases test Greg Kroah-Hartman
2020-09-21 16:27 ` Greg Kroah-Hartman [this message]
2020-09-21 16:27 ` [PATCH 5.8 061/118] perf evlist: Fix cpu/thread map leak Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 062/118] perf parse-event: Fix memory leak in evsel->unit Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 063/118] perf test: Free formats for perf pmu parse test Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 064/118] drm/i915/gem: Reduce context termination list iteration guard to RCU Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 065/118] fbcon: Fix user font detection test at fbcon_resize() Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 066/118] MIPS: SNI: Fix spurious interrupts Greg Kroah-Hartman
2020-09-21 16:27 ` [PATCH 5.8 067/118] drm/mediatek: Use CPU when fail to get cmdq event Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 068/118] drm/mediatek: Add missing put_device() call in mtk_ddp_comp_init() Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 069/118] drm/mediatek: Add exception handing in mtk_drm_probe() if component init fail Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 070/118] drm/mediatek: Add missing put_device() call in mtk_drm_kms_init() Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 071/118] drm/mediatek: Add missing put_device() call in mtk_hdmi_dt_parse_pdata() Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 072/118] arm64: bpf: Fix branch offset in JIT Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 073/118] iommu/amd: Fix potential @entry null deref Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 074/118] iommu/amd: Restore IRTE.RemapEn bit for amd_iommu_activate_guest_mode Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 075/118] kconfig: qconf: use delete[] instead of delete to free array (again) Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 076/118] i2c: mediatek: Fix generic definitions for bus frequency Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 077/118] i2c: mxs: use MXS_DMA_CTRL_WAIT4END instead of DMA_CTRL_ACK Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 078/118] riscv: Add sfence.vma after early page table changes Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 079/118] locking/lockdep: Fix "USED" <- "IN-NMI" inversions Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 080/118] efi: efibc: check for efivars write capability Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 081/118] locking/percpu-rwsem: Use this_cpu_{inc,dec}() for read_count Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 082/118] x86/unwind/fp: Fix FP unwinding in ret_from_fork Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 083/118] drm/kfd: fix a system crash issue during GPU recovery Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 084/118] drm/i915/gem: Delay tracking the GEM context until it is registered Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 085/118] drm/i915: Filter wake_flags passed to default_wake_function Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 086/118] USB: quirks: Add USB_QUIRK_IGNORE_REMOTE_WAKEUP quirk for BYD zhaoxin notebook Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 087/118] USB: UAS: fix disconnect by unplugging a hub Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 088/118] usblp: fix race between disconnect() and read() Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 089/118] usb: typec: ucsi: acpi: Increase command completion timeout value Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 090/118] usb: typec: ucsi: Prevent mode overrun Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 091/118] i2c: i801: Fix resume bug Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 092/118] Revert "ALSA: hda - Fix silent audio output and corrupted input on MSI X570-A PRO" Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 093/118] ALSA: hda: fixup headset for ASUS GX502 laptop Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 094/118] ALSA: hda/realtek - The Mic on a RedmiBook doesnt work Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 095/118] percpu: fix first chunk size calculation for populated bitmap Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 096/118] Input: trackpoint - add new trackpoint variant IDs Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 097/118] Input: i8042 - add Entroware Proteus EL07R4 to nomux and reset lists Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 098/118] thunderbolt: Retry DROM read once if parsing fails Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 099/118] serial: 8250_pci: Add Realtek 816a and 816b Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 100/118] serial: core: fix port-lock initialisation Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 101/118] serial: core: fix console port-lock regression Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 102/118] x86/boot/compressed: Disable relocation relaxation Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 103/118] ksm: reinstate memcg charge on copied pages Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 104/118] kprobes: fix kill kprobe which has been marked as gone Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 105/118] mm/thp: fix __split_huge_pmd_locked() for migration PMD Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 106/118] s390: add 3f program exception handler Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 107/118] s390/pci: fix leak of DMA tables on hard unplug Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 108/118] s390/zcrypt: fix kmalloc 256k failure Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 109/118] ehci-hcd: Move include to keep CRC stable Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 110/118] arm64: paravirt: Initialize steal time when cpu is online Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 111/118] powerpc/dma: Fix dma_map_ops::get_required_mask Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 112/118] selftests/vm: fix display of page size in map_hugetlb Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 113/118] dm/dax: Fix table reference counts Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 114/118] mm/memory_hotplug: drain per-cpu pages again during memory offline Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 115/118] dm: Call proper helper to determine dax support Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 116/118] dax: Fix compilation for CONFIG_DAX && !CONFIG_FS_DAX Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 117/118] mm: memcg: fix memcg reclaim soft lockup Greg Kroah-Hartman
2020-09-21 16:28 ` [PATCH 5.8 118/118] nvme-loop: set ctrl state connecting after init Greg Kroah-Hartman
2020-09-21 18:44 ` [PATCH 5.8 000/118] 5.8.11-rc1 review Geert Uytterhoeven
2020-09-23 11:00   ` Greg Kroah-Hartman
2020-09-22  5:02 ` Naresh Kamboju
2020-09-24 17:05   ` Greg Kroah-Hartman
2020-09-22 20:19 ` Guenter Roeck
2020-09-24 17:06   ` Greg Kroah-Hartman

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=20200921162039.141888218@linuxfoundation.org \
    --to=gregkh@linuxfoundation.org \
    --cc=acme@redhat.com \
    --cc=ak@linux.intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=eranian@google.com \
    --cc=irogers@google.com \
    --cc=john.garry@huawei.com \
    --cc=jolsa@redhat.com \
    --cc=kjain@linux.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    --cc=sashal@kernel.org \
    --cc=stable@vger.kernel.org \
    /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).