diff options
Diffstat (limited to 'tools/perf')
| -rw-r--r-- | tools/perf/builtin-report.c | 15 | ||||
| -rw-r--r-- | tools/perf/util/callchain.c | 7 | ||||
| -rw-r--r-- | tools/perf/util/callchain.h | 3 |
3 files changed, 11 insertions, 14 deletions
diff --git a/tools/perf/builtin-report.c b/tools/perf/builtin-report.c index 196473b51257..1cae87713792 100644 --- a/tools/perf/builtin-report.c +++ b/tools/perf/builtin-report.c | |||
| @@ -123,19 +123,6 @@ static int perf_session__add_hist_entry(struct perf_session *self, | |||
| 123 | return 0; | 123 | return 0; |
| 124 | } | 124 | } |
| 125 | 125 | ||
| 126 | static int validate_chain(struct ip_callchain *chain, event_t *event) | ||
| 127 | { | ||
| 128 | unsigned int chain_size; | ||
| 129 | |||
| 130 | chain_size = event->header.size; | ||
| 131 | chain_size -= (unsigned long)&event->ip.__more_data - (unsigned long)event; | ||
| 132 | |||
| 133 | if (chain->nr*sizeof(u64) > chain_size) | ||
| 134 | return -1; | ||
| 135 | |||
| 136 | return 0; | ||
| 137 | } | ||
| 138 | |||
| 139 | static int add_event_total(struct perf_session *session, | 126 | static int add_event_total(struct perf_session *session, |
| 140 | struct sample_data *data, | 127 | struct sample_data *data, |
| 141 | struct perf_event_attr *attr) | 128 | struct perf_event_attr *attr) |
| @@ -171,7 +158,7 @@ static int process_sample_event(event_t *event, struct perf_session *session) | |||
| 171 | 158 | ||
| 172 | dump_printf("... chain: nr:%Lu\n", data.callchain->nr); | 159 | dump_printf("... chain: nr:%Lu\n", data.callchain->nr); |
| 173 | 160 | ||
| 174 | if (validate_chain(data.callchain, event) < 0) { | 161 | if (!ip_callchain__valid(data.callchain, event)) { |
| 175 | pr_debug("call-chain problem with event, " | 162 | pr_debug("call-chain problem with event, " |
| 176 | "skipping it.\n"); | 163 | "skipping it.\n"); |
| 177 | return 0; | 164 | return 0; |
diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c index db628af6d20d..ac148613afe8 100644 --- a/tools/perf/util/callchain.c +++ b/tools/perf/util/callchain.c | |||
| @@ -17,6 +17,13 @@ | |||
| 17 | 17 | ||
| 18 | #include "callchain.h" | 18 | #include "callchain.h" |
| 19 | 19 | ||
| 20 | bool ip_callchain__valid(struct ip_callchain *chain, event_t *event) | ||
| 21 | { | ||
| 22 | unsigned int chain_size = event->header.size; | ||
| 23 | chain_size -= (unsigned long)&event->ip.__more_data - (unsigned long)event; | ||
| 24 | return chain->nr * sizeof(u64) <= chain_size; | ||
| 25 | } | ||
| 26 | |||
| 20 | #define chain_for_each_child(child, parent) \ | 27 | #define chain_for_each_child(child, parent) \ |
| 21 | list_for_each_entry(child, &parent->children, brothers) | 28 | list_for_each_entry(child, &parent->children, brothers) |
| 22 | 29 | ||
diff --git a/tools/perf/util/callchain.h b/tools/perf/util/callchain.h index 8a7e8bbd0fda..0f4da093cbd8 100644 --- a/tools/perf/util/callchain.h +++ b/tools/perf/util/callchain.h | |||
| @@ -4,6 +4,7 @@ | |||
| 4 | #include "../perf.h" | 4 | #include "../perf.h" |
| 5 | #include <linux/list.h> | 5 | #include <linux/list.h> |
| 6 | #include <linux/rbtree.h> | 6 | #include <linux/rbtree.h> |
| 7 | #include "event.h" | ||
| 7 | #include "util.h" | 8 | #include "util.h" |
| 8 | #include "symbol.h" | 9 | #include "symbol.h" |
| 9 | 10 | ||
| @@ -58,4 +59,6 @@ static inline u64 cumul_hits(struct callchain_node *node) | |||
| 58 | int register_callchain_param(struct callchain_param *param); | 59 | int register_callchain_param(struct callchain_param *param); |
| 59 | int append_chain(struct callchain_node *root, struct ip_callchain *chain, | 60 | int append_chain(struct callchain_node *root, struct ip_callchain *chain, |
| 60 | struct map_symbol *syms); | 61 | struct map_symbol *syms); |
| 62 | |||
| 63 | bool ip_callchain__valid(struct ip_callchain *chain, event_t *event); | ||
| 61 | #endif /* __PERF_CALLCHAIN_H */ | 64 | #endif /* __PERF_CALLCHAIN_H */ |
