diff options
author | Kan Liang <kan.liang@linux.intel.com> | 2024-09-05 19:07:37 +0200 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2024-09-06 16:45:28 +0200 |
commit | 003265bb6f028d7bcd7cbd92d6ba2b4e26382796 (patch) | |
tree | e35c1d82e373eadab186d26a0897106a167e728e /tools/perf/builtin-mem.c | |
parent | perf mem: Fix missed p-core mem events on ADL and RPL (diff) | |
download | linux-003265bb6f028d7bcd7cbd92d6ba2b4e26382796.tar.xz linux-003265bb6f028d7bcd7cbd92d6ba2b4e26382796.zip |
perf mem: Fix the wrong reference in parse_record_events()
A segmentation fault can be triggered when running
'perf mem record -e ldlat-loads'
The commit 35b38a71c92fa033 ("perf mem: Rework command option handling")
moves the OPT_CALLBACK of event from __cmd_record() to cmd_mem().
When invoking the __cmd_record(), the 'mem' has been referenced (&).
So the &mem passed into the parse_record_events() is a double reference
(&&) of the original struct perf_mem mem.
But in the cmd_mem(), the &mem is the single reference (&) of the
original struct perf_mem mem.
Fixes: 35b38a71c92fa033 ("perf mem: Rework command option handling")
Signed-off-by: Kan Liang <kan.liang@linux.intel.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Link: https://lore.kernel.org/r/20240905170737.4070743-3-kan.liang@linux.intel.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/builtin-mem.c')
-rw-r--r-- | tools/perf/builtin-mem.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/perf/builtin-mem.c b/tools/perf/builtin-mem.c index 615e905450b3..651188c1d825 100644 --- a/tools/perf/builtin-mem.c +++ b/tools/perf/builtin-mem.c @@ -47,7 +47,7 @@ struct perf_mem { static int parse_record_events(const struct option *opt, const char *str, int unset __maybe_unused) { - struct perf_mem *mem = *(struct perf_mem **)opt->value; + struct perf_mem *mem = (struct perf_mem *)opt->value; struct perf_pmu *pmu; pmu = perf_mem_events_find_pmu(); |