From 13edbb7d5e8ce8cf4788aee11debafa30cf676b7 Mon Sep 17 00:00:00 2001 From: Thomas Richter Date: Thu, 20 Oct 2022 14:06:28 +0200 Subject: [PATCH] cpumf/pai: fix core dump when summary flag set MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit pai dumps core when invoked with summary flag -S and certain painnpa.XXXXX data files: # ~/s390-tools/cpumf/pai -r -S Segmentation fault (core dumped) # Fix this and check the existence of event raw data before reading it. This avoid accessing NULL pointer trying to read raw data when no counter values have been appended as raw data by the kernel. Fixes: dc73c77d7317 ("cpumf/pai: Omit detailed event information when summary flag selected") Signed-off-by: Thomas Richter Signed-off-by: Jan Höppner --- cpumf/pai.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cpumf/pai.c b/cpumf/pai.c index c4d726e6..6c06f9e8 100644 --- a/cpumf/pai.c +++ b/cpumf/pai.c @@ -426,7 +426,7 @@ static const char *evt_selector(struct perf_event_attr *pa) static void evt_show(__u64 evtnum, const char *evtsel, struct pai_event_out *ev) { if (summary) { - if (ev->type == PERF_RECORD_SAMPLE) + if (ev->type == PERF_RECORD_SAMPLE && ev->raw) evtraw_show(evtnum, ev->raw); return; }