aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorSteven Rostedt <rostedt@goodmis.org>2012-10-01 20:13:51 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2012-10-16 12:06:36 -0400
commit101782ea2c6984cf169631c59df76b8497899caf (patch)
tree500c3a43f6698e1b42b093a576eaefc8ea934504 /tools
parent63a1a3d820c619a4dab1781cc16c110a284efded (diff)
lib tools traceevent: Add back pevent assignment in __pevent_parse_format()
Even though with the change of commit commit 2b29175 "tools lib traceevent: Carve out events format parsing routine", allowed __pevent_parse_format() to parse an event without the need of a pevent handler, the event still needs to assign the pevent handed to it. There's no problem with assigning it if the pevent is NULL, as the event->pevent would be NULL without the assignment. But function parsing handlers may be assigned to the pevent handler to help in parsing the event. If there's no pevent then there would not be any function handlers, but if the pevent isn't assigned first before parsing the event, it wont honor the function handlers that were assigned. Worse yet, the current code crashes if an event has a function that it tries to parse. For example: # perf record -e scsi:scsi_dispatch_cmd_timeout Segmentation fault (core dumped) This happens because the scsi_dispatch_cmd_timeout event format has the following: scsi_trace_parse_cdb(p, __get_dynamic_array(cmnd), REC->cmd_len) which hasn't been defined by the pevent code. Signed-off-by: Steven Rostedt <rostedt@goodmis.org> Reviewed-by: Namhyung Kim <namhyung@kernel.org> Cc: Ingo Molnar <mingo@kernel.org> Cc: Namhyung Kim <namhyung@kernel.org> Link: http://lkml.kernel.org/r/1349136831.22822.133.camel@gandalf.local.home Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/lib/traceevent/event-parse.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 47264b4652b9..f2989c525e48 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -2602,6 +2602,9 @@ find_func_handler(struct pevent *pevent, char *func_name)
2602{ 2602{
2603 struct pevent_function_handler *func; 2603 struct pevent_function_handler *func;
2604 2604
2605 if (!pevent)
2606 return NULL;
2607
2605 for (func = pevent->func_handlers; func; func = func->next) { 2608 for (func = pevent->func_handlers; func; func = func->next) {
2606 if (strcmp(func->name, func_name) == 0) 2609 if (strcmp(func->name, func_name) == 0)
2607 break; 2610 break;
@@ -4938,6 +4941,9 @@ enum pevent_errno __pevent_parse_format(struct event_format **eventp,
4938 goto event_alloc_failed; 4941 goto event_alloc_failed;
4939 } 4942 }
4940 4943
4944 /* Add pevent to event so that it can be referenced */
4945 event->pevent = pevent;
4946
4941 ret = event_read_format(event); 4947 ret = event_read_format(event);
4942 if (ret < 0) { 4948 if (ret < 0) {
4943 ret = PEVENT_ERRNO__READ_FORMAT_FAILED; 4949 ret = PEVENT_ERRNO__READ_FORMAT_FAILED;
@@ -5041,9 +5047,6 @@ enum pevent_errno pevent_parse_event(struct pevent *pevent, const char *buf,
5041 if (event == NULL) 5047 if (event == NULL)
5042 return ret; 5048 return ret;
5043 5049
5044 /* Add pevent to event so that it can be referenced */
5045 event->pevent = pevent;
5046
5047 if (add_event(pevent, event)) { 5050 if (add_event(pevent, event)) {
5048 ret = PEVENT_ERRNO__MEM_ALLOC_FAILED; 5051 ret = PEVENT_ERRNO__MEM_ALLOC_FAILED;
5049 goto event_add_failed; 5052 goto event_add_failed;