diff options
-rw-r--r-- | tools/lib/traceevent/event-parse.c | 26 | ||||
-rw-r--r-- | tools/lib/traceevent/event-parse.h | 3 |
2 files changed, 22 insertions, 7 deletions
diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c index 17fd01d46e60..4595aeb3c432 100644 --- a/tools/lib/traceevent/event-parse.c +++ b/tools/lib/traceevent/event-parse.c | |||
@@ -5080,6 +5080,7 @@ int pevent_register_print_function(struct pevent *pevent, | |||
5080 | struct pevent_func_params *param; | 5080 | struct pevent_func_params *param; |
5081 | enum pevent_func_arg_type type; | 5081 | enum pevent_func_arg_type type; |
5082 | va_list ap; | 5082 | va_list ap; |
5083 | int ret; | ||
5083 | 5084 | ||
5084 | func_handle = find_func_handler(pevent, name); | 5085 | func_handle = find_func_handler(pevent, name); |
5085 | if (func_handle) { | 5086 | if (func_handle) { |
@@ -5092,14 +5093,21 @@ int pevent_register_print_function(struct pevent *pevent, | |||
5092 | remove_func_handler(pevent, name); | 5093 | remove_func_handler(pevent, name); |
5093 | } | 5094 | } |
5094 | 5095 | ||
5095 | func_handle = malloc_or_die(sizeof(*func_handle)); | 5096 | func_handle = malloc(sizeof(*func_handle)); |
5097 | if (!func_handle) { | ||
5098 | do_warning("Failed to allocate function handler"); | ||
5099 | return PEVENT_ERRNO__MEM_ALLOC_FAILED; | ||
5100 | } | ||
5096 | memset(func_handle, 0, sizeof(*func_handle)); | 5101 | memset(func_handle, 0, sizeof(*func_handle)); |
5097 | 5102 | ||
5098 | func_handle->ret_type = ret_type; | 5103 | func_handle->ret_type = ret_type; |
5099 | func_handle->name = strdup(name); | 5104 | func_handle->name = strdup(name); |
5100 | func_handle->func = func; | 5105 | func_handle->func = func; |
5101 | if (!func_handle->name) | 5106 | if (!func_handle->name) { |
5102 | die("Failed to allocate function name"); | 5107 | do_warning("Failed to allocate function name"); |
5108 | free(func_handle); | ||
5109 | return PEVENT_ERRNO__MEM_ALLOC_FAILED; | ||
5110 | } | ||
5103 | 5111 | ||
5104 | next_param = &(func_handle->params); | 5112 | next_param = &(func_handle->params); |
5105 | va_start(ap, name); | 5113 | va_start(ap, name); |
@@ -5109,11 +5117,17 @@ int pevent_register_print_function(struct pevent *pevent, | |||
5109 | break; | 5117 | break; |
5110 | 5118 | ||
5111 | if (type < 0 || type >= PEVENT_FUNC_ARG_MAX_TYPES) { | 5119 | if (type < 0 || type >= PEVENT_FUNC_ARG_MAX_TYPES) { |
5112 | warning("Invalid argument type %d", type); | 5120 | do_warning("Invalid argument type %d", type); |
5121 | ret = PEVENT_ERRNO__INVALID_ARG_TYPE; | ||
5113 | goto out_free; | 5122 | goto out_free; |
5114 | } | 5123 | } |
5115 | 5124 | ||
5116 | param = malloc_or_die(sizeof(*param)); | 5125 | param = malloc(sizeof(*param)); |
5126 | if (!param) { | ||
5127 | do_warning("Failed to allocate function param"); | ||
5128 | ret = PEVENT_ERRNO__MEM_ALLOC_FAILED; | ||
5129 | goto out_free; | ||
5130 | } | ||
5117 | param->type = type; | 5131 | param->type = type; |
5118 | param->next = NULL; | 5132 | param->next = NULL; |
5119 | 5133 | ||
@@ -5131,7 +5145,7 @@ int pevent_register_print_function(struct pevent *pevent, | |||
5131 | out_free: | 5145 | out_free: |
5132 | va_end(ap); | 5146 | va_end(ap); |
5133 | free_func_handle(func_handle); | 5147 | free_func_handle(func_handle); |
5134 | return -1; | 5148 | return ret; |
5135 | } | 5149 | } |
5136 | 5150 | ||
5137 | /** | 5151 | /** |
diff --git a/tools/lib/traceevent/event-parse.h b/tools/lib/traceevent/event-parse.h index 863a0bbda7f1..3318963f1c98 100644 --- a/tools/lib/traceevent/event-parse.h +++ b/tools/lib/traceevent/event-parse.h | |||
@@ -351,7 +351,8 @@ enum pevent_flag { | |||
351 | _PE(READ_ID_FAILED, "failed to read event id"), \ | 351 | _PE(READ_ID_FAILED, "failed to read event id"), \ |
352 | _PE(READ_FORMAT_FAILED, "failed to read event format"), \ | 352 | _PE(READ_FORMAT_FAILED, "failed to read event format"), \ |
353 | _PE(READ_PRINT_FAILED, "failed to read event print fmt"), \ | 353 | _PE(READ_PRINT_FAILED, "failed to read event print fmt"), \ |
354 | _PE(OLD_FTRACE_ARG_FAILED,"failed to allocate field name for ftrace") | 354 | _PE(OLD_FTRACE_ARG_FAILED,"failed to allocate field name for ftrace"),\ |
355 | _PE(INVALID_ARG_TYPE, "invalid argument type") | ||
355 | 356 | ||
356 | #undef _PE | 357 | #undef _PE |
357 | #define _PE(__code, __str) PEVENT_ERRNO__ ## __code | 358 | #define _PE(__code, __str) PEVENT_ERRNO__ ## __code |