diff mbox series

[v2,15/16] perf parse-events: Minor grouping tidy up

Message ID 20240416061533.921723-16-irogers@google.com (mailing list archive)
State Handled Elsewhere
Headers show
Series Consistently prefer sysfs/json events | expand

Checks

Context Check Description
conchuod/vmtest-fixes-PR fail merge-conflict
conchuod/vmtest-for-next-PR success PR summary
conchuod/patch-15-test-1 success .github/scripts/patches/tests/build_rv32_defconfig.sh
conchuod/patch-15-test-2 success .github/scripts/patches/tests/build_rv64_clang_allmodconfig.sh
conchuod/patch-15-test-3 success .github/scripts/patches/tests/build_rv64_gcc_allmodconfig.sh
conchuod/patch-15-test-4 success .github/scripts/patches/tests/build_rv64_nommu_k210_defconfig.sh
conchuod/patch-15-test-5 success .github/scripts/patches/tests/build_rv64_nommu_virt_defconfig.sh
conchuod/patch-15-test-6 success .github/scripts/patches/tests/checkpatch.sh
conchuod/patch-15-test-7 success .github/scripts/patches/tests/dtb_warn_rv64.sh
conchuod/patch-15-test-8 success .github/scripts/patches/tests/header_inline.sh
conchuod/patch-15-test-9 success .github/scripts/patches/tests/kdoc.sh
conchuod/patch-15-test-10 success .github/scripts/patches/tests/module_param.sh
conchuod/patch-15-test-11 success .github/scripts/patches/tests/verify_fixes.sh
conchuod/patch-15-test-12 success .github/scripts/patches/tests/verify_signedoff.sh

Commit Message

Ian Rogers April 16, 2024, 6:15 a.m. UTC
Add comments. Ensure leader->group_name is freed before overwriting
it.

Signed-off-by: Ian Rogers <irogers@google.com>
---
 tools/perf/util/parse-events.c | 1 +
 tools/perf/util/parse-events.y | 6 +++++-
 2 files changed, 6 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index 8d3d692d219d..1c1b1bcb78e8 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -1711,6 +1711,7 @@  void parse_events__set_leader(char *name, struct list_head *list)
 
 	leader = list_first_entry(list, struct evsel, core.node);
 	__perf_evlist__set_leader(list, &leader->core);
+	zfree(&leader->group_name);
 	leader->group_name = name;
 }
 
diff --git a/tools/perf/util/parse-events.y b/tools/perf/util/parse-events.y
index 79f254189be6..6f1042272dda 100644
--- a/tools/perf/util/parse-events.y
+++ b/tools/perf/util/parse-events.y
@@ -193,7 +193,10 @@  PE_NAME '{' events '}'
 {
 	struct list_head *list = $3;
 
-	/* Takes ownership of $1. */
+	/*
+	 * Set the first entry of list to be the leader. Set the group name on
+	 * the leader to $1 taking ownership.
+	 */
 	parse_events__set_leader($1, list);
 	$$ = list;
 }
@@ -202,6 +205,7 @@  PE_NAME '{' events '}'
 {
 	struct list_head *list = $2;
 
+	/* Set the first entry of list to be the leader clearing the group name. */
 	parse_events__set_leader(NULL, list);
 	$$ = list;
 }