Commit b7823045 authored by Ian Rogers's avatar Ian Rogers Committed by Arnaldo Carvalho de Melo

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: default avatarIan Rogers <irogers@google.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Athira Rajeev <atrajeev@linux.vnet.ibm.com>
Cc: Huacai Chen <chenhuacai@kernel.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: James Clark <james.clark@arm.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: John Garry <john.g.garry@oracle.com>
Cc: K Prateek Nayak <kprateek.nayak@amd.com>
Cc: Kajol Jain <kjain@linux.ibm.com>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Leo Yan <leo.yan@linaro.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Mike Leach <mike.leach@linaro.org>
Cc: Ming Wang <wangming01@loongson.cn>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Ravi Bangoria <ravi.bangoria@amd.com>
Cc: Sean Christopherson <seanjc@google.com>
Cc: Suzuki Poulouse <suzuki.poulose@arm.com>
Cc: Wei Li <liwei391@huawei.com>
Cc: Will Deacon <will@kernel.org>
Cc: linux-arm-kernel@lists.infradead.org
Link: https://lore.kernel.org/r/20230825024002.801955-5-irogers@google.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 970ef02e
...@@ -684,7 +684,7 @@ static struct perf_pmu_test_pmu test_pmus[] = { ...@@ -684,7 +684,7 @@ static struct perf_pmu_test_pmu test_pmus[] = {
.pmu = { .pmu = {
.name = "uncore_sys_ddr_pmu0", .name = "uncore_sys_ddr_pmu0",
.is_uncore = 1, .is_uncore = 1,
.id = (char *)"v8", .id = "v8",
}, },
.aliases = { .aliases = {
&sys_ddr_pmu_write_cycles, &sys_ddr_pmu_write_cycles,
...@@ -694,7 +694,7 @@ static struct perf_pmu_test_pmu test_pmus[] = { ...@@ -694,7 +694,7 @@ static struct perf_pmu_test_pmu test_pmus[] = {
.pmu = { .pmu = {
.name = "uncore_sys_ccn_pmu4", .name = "uncore_sys_ccn_pmu4",
.is_uncore = 1, .is_uncore = 1,
.id = (char *)"0x01", .id = "0x01",
}, },
.aliases = { .aliases = {
&sys_ccn_pmu_read_cycles, &sys_ccn_pmu_read_cycles,
......
...@@ -2056,6 +2056,7 @@ void perf_pmu__delete(struct perf_pmu *pmu) ...@@ -2056,6 +2056,7 @@ void perf_pmu__delete(struct perf_pmu *pmu)
zfree(&pmu->default_config); zfree(&pmu->default_config);
zfree(&pmu->name); zfree(&pmu->name);
zfree(&pmu->alias_name); zfree(&pmu->alias_name);
zfree(&pmu->id);
free(pmu); free(pmu);
} }
......
...@@ -49,7 +49,7 @@ struct perf_pmu { ...@@ -49,7 +49,7 @@ struct perf_pmu {
* @id: Optional PMU identifier read from * @id: Optional PMU identifier read from
* <sysfs>/bus/event_source/devices/<name>/identifier. * <sysfs>/bus/event_source/devices/<name>/identifier.
*/ */
char *id; const char *id;
/** /**
* @type: Perf event attributed type value, read from * @type: Perf event attributed type value, read from
* <sysfs>/bus/event_source/devices/<name>/type. * <sysfs>/bus/event_source/devices/<name>/type.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment