aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIan Rogers <[email protected]>2023-08-24 19:40:00 -0700
committerArnaldo Carvalho de Melo <[email protected]>2023-08-25 10:23:34 -0300
commitb7823045ec1ab7bb79e206a17705f92d6ff4ff32 (patch)
tree221bcdd9a30efa11dcc7c5f9f3c738573a0727eb
parent970ef02e980aea5391d87e425defc5e814823b3a (diff)
perf pmu: Make id const and add missing free
The struct pmu id is initialized from pmu_id that is read into allocated memory from a file, as such it needs free-ing in pmu__delete(). Make the id value const so that we can remove casts in tests. Signed-off-by: Ian Rogers <[email protected]> Cc: Adrian Hunter <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Athira Rajeev <[email protected]> Cc: Huacai Chen <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: James Clark <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: John Garry <[email protected]> Cc: K Prateek Nayak <[email protected]> Cc: Kajol Jain <[email protected]> Cc: Kan Liang <[email protected]> Cc: Leo Yan <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Mike Leach <[email protected]> Cc: Ming Wang <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Ravi Bangoria <[email protected]> Cc: Sean Christopherson <[email protected]> Cc: Suzuki Poulouse <[email protected]> Cc: Wei Li <[email protected]> Cc: Will Deacon <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
-rw-r--r--tools/perf/tests/pmu-events.c4
-rw-r--r--tools/perf/util/pmu.c1
-rw-r--r--tools/perf/util/pmu.h2
3 files changed, 4 insertions, 3 deletions
diff --git a/tools/perf/tests/pmu-events.c b/tools/perf/tests/pmu-events.c
index d92de3d5365e..ce4da9b1d115 100644
--- a/tools/perf/tests/pmu-events.c
+++ b/tools/perf/tests/pmu-events.c
@@ -684,7 +684,7 @@ static struct perf_pmu_test_pmu test_pmus[] = {
.pmu = {
.name = "uncore_sys_ddr_pmu0",
.is_uncore = 1,
- .id = (char *)"v8",
+ .id = "v8",
},
.aliases = {
&sys_ddr_pmu_write_cycles,
@@ -694,7 +694,7 @@ static struct perf_pmu_test_pmu test_pmus[] = {
.pmu = {
.name = "uncore_sys_ccn_pmu4",
.is_uncore = 1,
- .id = (char *)"0x01",
+ .id = "0x01",
},
.aliases = {
&sys_ccn_pmu_read_cycles,
diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index eb42f9830be7..b92dc7237f3b 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -2056,6 +2056,7 @@ void perf_pmu__delete(struct perf_pmu *pmu)
zfree(&pmu->default_config);
zfree(&pmu->name);
zfree(&pmu->alias_name);
+ zfree(&pmu->id);
free(pmu);
}
diff --git a/tools/perf/util/pmu.h b/tools/perf/util/pmu.h
index e90169ab3dc2..73965f208009 100644
--- a/tools/perf/util/pmu.h
+++ b/tools/perf/util/pmu.h
@@ -49,7 +49,7 @@ struct perf_pmu {
* @id: Optional PMU identifier read from
* <sysfs>/bus/event_source/devices/<name>/identifier.
*/
- char *id;
+ const char *id;
/**
* @type: Perf event attributed type value, read from
* <sysfs>/bus/event_source/devices/<name>/type.