diff options
-rw-r--r-- | tools/perf/builtin-record.c | 5 | ||||
-rw-r--r-- | tools/perf/util/header.c | 22 | ||||
-rw-r--r-- | tools/perf/util/header.h | 4 |
3 files changed, 17 insertions, 14 deletions
diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index 04f335ef9a8c..4c03bb7a4eba 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c | |||
@@ -220,7 +220,8 @@ static struct perf_header_attr *get_header_attr(struct perf_event_attr *a, int n | |||
220 | h_attr = header->attr[nr]; | 220 | h_attr = header->attr[nr]; |
221 | } else { | 221 | } else { |
222 | h_attr = perf_header_attr__new(a); | 222 | h_attr = perf_header_attr__new(a); |
223 | perf_header__add_attr(header, h_attr); | 223 | if (h_attr != NULL) |
224 | perf_header__add_attr(header, h_attr); | ||
224 | } | 225 | } |
225 | 226 | ||
226 | return h_attr; | 227 | return h_attr; |
@@ -308,6 +309,8 @@ try_again: | |||
308 | } | 309 | } |
309 | 310 | ||
310 | h_attr = get_header_attr(attr, counter); | 311 | h_attr = get_header_attr(attr, counter); |
312 | if (h_attr == NULL) | ||
313 | die("nomem\n"); | ||
311 | 314 | ||
312 | if (!file_new) { | 315 | if (!file_new) { |
313 | if (memcmp(&h_attr->attr, attr, sizeof(*attr))) { | 316 | if (memcmp(&h_attr->attr, attr, sizeof(*attr))) { |
diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index d8416f011179..2f07a238ffdf 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c | |||
@@ -19,16 +19,16 @@ struct perf_header_attr *perf_header_attr__new(struct perf_event_attr *attr) | |||
19 | { | 19 | { |
20 | struct perf_header_attr *self = malloc(sizeof(*self)); | 20 | struct perf_header_attr *self = malloc(sizeof(*self)); |
21 | 21 | ||
22 | if (!self) | 22 | if (self != NULL) { |
23 | die("nomem"); | 23 | self->attr = *attr; |
24 | 24 | self->ids = 0; | |
25 | self->attr = *attr; | 25 | self->size = 1; |
26 | self->ids = 0; | 26 | self->id = malloc(sizeof(u64)); |
27 | self->size = 1; | 27 | if (self->id == NULL) { |
28 | self->id = malloc(sizeof(u64)); | 28 | free(self); |
29 | 29 | self = NULL; | |
30 | if (!self->id) | 30 | } |
31 | die("nomem"); | 31 | } |
32 | 32 | ||
33 | return self; | 33 | return self; |
34 | } | 34 | } |
@@ -423,6 +423,8 @@ struct perf_header *perf_header__read(int fd) | |||
423 | tmp = lseek(fd, 0, SEEK_CUR); | 423 | tmp = lseek(fd, 0, SEEK_CUR); |
424 | 424 | ||
425 | attr = perf_header_attr__new(&f_attr.attr); | 425 | attr = perf_header_attr__new(&f_attr.attr); |
426 | if (attr == NULL) | ||
427 | die("nomem"); | ||
426 | 428 | ||
427 | nr_ids = f_attr.ids.size / sizeof(u64); | 429 | nr_ids = f_attr.ids.size / sizeof(u64); |
428 | lseek(fd, f_attr.ids.offset, SEEK_SET); | 430 | lseek(fd, f_attr.ids.offset, SEEK_SET); |
diff --git a/tools/perf/util/header.h b/tools/perf/util/header.h index f1b3bf7bdfc1..0cbd4c9e982c 100644 --- a/tools/perf/util/header.h +++ b/tools/perf/util/header.h | |||
@@ -64,9 +64,7 @@ void perf_header__add_attr(struct perf_header *self, | |||
64 | void perf_header__push_event(u64 id, const char *name); | 64 | void perf_header__push_event(u64 id, const char *name); |
65 | char *perf_header__find_event(u64 id); | 65 | char *perf_header__find_event(u64 id); |
66 | 66 | ||
67 | 67 | struct perf_header_attr *perf_header_attr__new(struct perf_event_attr *attr); | |
68 | struct perf_header_attr * | ||
69 | perf_header_attr__new(struct perf_event_attr *attr); | ||
70 | void perf_header_attr__add_id(struct perf_header_attr *self, u64 id); | 68 | void perf_header_attr__add_id(struct perf_header_attr *self, u64 id); |
71 | 69 | ||
72 | u64 perf_header__sample_type(struct perf_header *header); | 70 | u64 perf_header__sample_type(struct perf_header *header); |