diff options
| author | Namhyung Kim <[email protected]> | 2024-05-10 21:04:51 +0000 |
|---|---|---|
| committer | Arnaldo Carvalho de Melo <[email protected]> | 2024-05-11 16:03:13 +0000 |
| commit | 9ef30265a483f0405e4f7b3f15cda251b9a2c7da (patch) | |
| tree | 635f98127b16db9ece0e2b96b963a4ea3845fc06 /tools/perf/util/annotate.c | |
| parent | perf daemon: Fix file leak in daemon_session__control (diff) | |
| download | kernel-9ef30265a483f0405e4f7b3f15cda251b9a2c7da.tar.gz kernel-9ef30265a483f0405e4f7b3f15cda251b9a2c7da.zip | |
perf annotate: Fix segfault on sample histogram
A symbol can have no samples, then accessing the annotated_source->samples
hashmap will result in a segfault.
Fixes: a3f7768bcf48281d ("perf annotate: Fix memory leak in annotated_source")
Reviewed-by: Ian Rogers <[email protected]>
Signed-off-by: Namhyung Kim <[email protected]>
Cc: Adrian Hunter <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Kan Liang <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
Diffstat (limited to 'tools/perf/util/annotate.c')
| -rw-r--r-- | tools/perf/util/annotate.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/tools/perf/util/annotate.c b/tools/perf/util/annotate.c index 541988cf6e19..1451caf25e77 100644 --- a/tools/perf/util/annotate.c +++ b/tools/perf/util/annotate.c @@ -113,10 +113,11 @@ static __maybe_unused void annotated_source__delete(struct annotated_source *src if (src == NULL) return; - hashmap__for_each_entry(src->samples, cur, bkt) - zfree(&cur->pvalue); - - hashmap__free(src->samples); + if (src->samples) { + hashmap__for_each_entry(src->samples, cur, bkt) + zfree(&cur->pvalue); + hashmap__free(src->samples); + } zfree(&src->histograms); free(src); } |
