aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/header.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/util/header.c')
-rw-r--r--tools/perf/util/header.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c
index c24db7f4909c..1903d7ec9797 100644
--- a/tools/perf/util/header.c
+++ b/tools/perf/util/header.c
@@ -3559,6 +3559,13 @@ int perf_session__read_header(struct perf_session *session)
3559 data->file.path); 3559 data->file.path);
3560 } 3560 }
3561 3561
3562 if (f_header.attr_size == 0) {
3563 pr_err("ERROR: The %s file's attr size field is 0 which is unexpected.\n"
3564 "Was the 'perf record' command properly terminated?\n",
3565 data->file.path);
3566 return -EINVAL;
3567 }
3568
3562 nr_attrs = f_header.attrs.size / f_header.attr_size; 3569 nr_attrs = f_header.attrs.size / f_header.attr_size;
3563 lseek(fd, f_header.attrs.offset, SEEK_SET); 3570 lseek(fd, f_header.attrs.offset, SEEK_SET);
3564 3571
@@ -3639,7 +3646,7 @@ int perf_event__synthesize_attr(struct perf_tool *tool,
3639 size += sizeof(struct perf_event_header); 3646 size += sizeof(struct perf_event_header);
3640 size += ids * sizeof(u64); 3647 size += ids * sizeof(u64);
3641 3648
3642 ev = malloc(size); 3649 ev = zalloc(size);
3643 3650
3644 if (ev == NULL) 3651 if (ev == NULL)
3645 return -ENOMEM; 3652 return -ENOMEM;
@@ -3747,7 +3754,7 @@ int perf_event__process_feature(struct perf_session *session,
3747 return 0; 3754 return 0;
3748 3755
3749 ff.buf = (void *)fe->data; 3756 ff.buf = (void *)fe->data;
3750 ff.size = event->header.size - sizeof(event->header); 3757 ff.size = event->header.size - sizeof(*fe);
3751 ff.ph = &session->header; 3758 ff.ph = &session->header;
3752 3759
3753 if (feat_ops[feat].process(&ff, NULL)) 3760 if (feat_ops[feat].process(&ff, NULL))