aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/builtin-timechart.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/perf/builtin-timechart.c')
-rw-r--r--tools/perf/builtin-timechart.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/tools/perf/builtin-timechart.c b/tools/perf/builtin-timechart.c
index 665877e4a944..dd4d82ac7aa4 100644
--- a/tools/perf/builtin-timechart.c
+++ b/tools/perf/builtin-timechart.c
@@ -1093,7 +1093,7 @@ static void process_samples(void)
1093 1093
1094static int __cmd_timechart(void) 1094static int __cmd_timechart(void)
1095{ 1095{
1096 int ret, rc = EXIT_FAILURE; 1096 int err, rc = EXIT_FAILURE;
1097 unsigned long offset = 0; 1097 unsigned long offset = 0;
1098 unsigned long head, shift; 1098 unsigned long head, shift;
1099 struct stat statbuf; 1099 struct stat statbuf;
@@ -1111,8 +1111,8 @@ static int __cmd_timechart(void)
1111 exit(-1); 1111 exit(-1);
1112 } 1112 }
1113 1113
1114 ret = fstat(input, &statbuf); 1114 err = fstat(input, &statbuf);
1115 if (ret < 0) { 1115 if (err < 0) {
1116 perror("failed to stat file"); 1116 perror("failed to stat file");
1117 exit(-1); 1117 exit(-1);
1118 } 1118 }
@@ -1122,7 +1122,16 @@ static int __cmd_timechart(void)
1122 exit(0); 1122 exit(0);
1123 } 1123 }
1124 1124
1125 header = perf_header__read(input); 1125 header = perf_header__new();
1126 if (header == NULL)
1127 return -ENOMEM;
1128
1129 err = perf_header__read(header, input);
1130 if (err < 0) {
1131 perf_header__delete(header);
1132 return err;
1133 }
1134
1126 head = header->data_offset; 1135 head = header->data_offset;
1127 1136
1128 sample_type = perf_header__sample_type(header); 1137 sample_type = perf_header__sample_type(header);