[PATCH 1/1] perf pmu: Use perf_cpu_map__set_nr() in perf_pmu__cpus_match() to allow for refcnt checking

From: Arnaldo Carvalho de Melo
Date: Wed Apr 12 2023 - 13:56:28 EST


One more step to allow for checking reference counting, user after free,
etc.

Cc: Adrian Hunter <adrian.hunter@xxxxxxxxx>
Cc: Alexey Bayduraev <alexey.v.bayduraev@xxxxxxxxxxxxxxx>
Cc: Dmitriy Vyukov <dvyukov@xxxxxxxxxx>
Cc: Ian Rogers <irogers@xxxxxxxxxx>
Cc: Jiri Olsa <jolsa@xxxxxxxxxx>
Cc: Namhyung Kim <namhyung@xxxxxxxxxx>
Cc: Riccardo Mancini <rickyman7@xxxxxxxxx>
Cc: Stephane Eranian <eranian@xxxxxxxxxx>
Cc: Stephen Brennan <stephen.s.brennan@xxxxxxxxxx>
Link: https://lore.kernel.org/
Signed-off-by: Arnaldo Carvalho de Melo <acme@xxxxxxxxxx>
---
tools/perf/util/pmu.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/pmu.c b/tools/perf/util/pmu.c
index 561e2616861f8bd9..760c848c9fa27728 100644
--- a/tools/perf/util/pmu.c
+++ b/tools/perf/util/pmu.c
@@ -2020,8 +2020,8 @@ int perf_pmu__cpus_match(struct perf_pmu *pmu, struct perf_cpu_map *cpus,
matched_cpus->map[matched_nr++] = cpu;
}

- unmatched_cpus->nr = unmatched_nr;
- matched_cpus->nr = matched_nr;
+ perf_cpu_map__set_nr(unmatched_cpus, unmatched_nr);
+ perf_cpu_map__set_nr(matched_cpus, matched_nr);
*mcpus_ptr = matched_cpus;
*ucpus_ptr = unmatched_cpus;
return 0;
--
2.39.2