perf annotate-data: Ensure the number of type histograms
authorNamhyung Kim <namhyung@kernel.org>
Fri, 10 May 2024 21:04:52 +0000 (14:04 -0700)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Sat, 11 May 2024 16:03:13 +0000 (13:03 -0300)
commit2af1280b190c408bd590704806dd0d2d1cf52db5
tree7b4f50271df04a6c7def75141b718789812da6a3
parent9ef30265a483f0405e4f7b3f15cda251b9a2c7da
perf annotate-data: Ensure the number of type histograms

Arnaldo reported that there is a case where nr_histograms and histograms
don't agree each other.

It ended up in a segfault trying to access a NULL histograms array.

Let's make sure to update the nr_histograms when the histograms array is
changed.

Reported-by: Arnaldo Carvalho de Melo <acme@kernel.org>
Reviewed-by: Ian Rogers <irogers@google.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Kan Liang <kan.liang@linux.intel.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20240510210452.2449944-2-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/annotate-data.c