tools lib traceevent: Handle strdup failure cases
There were some places didn't check return value of the strdup and had unneeded/duplicated checks. Fix it. Signed-off-by: Namhyung Kim <namhyung.kim@lge.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Cc: Arnaldo Carvalho de Melo <acme@infradead.org> Cc: Borislav Petkov <bp@alien8.de> Cc: David Ahern <dsahern@gmail.com> Link: http://lkml.kernel.org/r/1333940074-19052-5-git-send-email-namhyung.kim@lge.com Signed-off-by: Steven Rostedt <rostedt@goodmis.org> Signed-off-by: Namhyung Kim <namhyung@kernel.org>
This commit is contained in:
parent
deba3fb26f
commit
ca63858e9e
1 changed files with 27 additions and 2 deletions
|
@ -467,8 +467,10 @@ int pevent_register_function(struct pevent *pevent, char *func,
|
||||||
item->mod = NULL;
|
item->mod = NULL;
|
||||||
item->addr = addr;
|
item->addr = addr;
|
||||||
|
|
||||||
pevent->funclist = item;
|
if (!item->func || (mod && !item->mod))
|
||||||
|
die("malloc func");
|
||||||
|
|
||||||
|
pevent->funclist = item;
|
||||||
pevent->func_count++;
|
pevent->func_count++;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -583,10 +585,13 @@ int pevent_register_print_string(struct pevent *pevent, char *fmt,
|
||||||
item = malloc_or_die(sizeof(*item));
|
item = malloc_or_die(sizeof(*item));
|
||||||
|
|
||||||
item->next = pevent->printklist;
|
item->next = pevent->printklist;
|
||||||
pevent->printklist = item;
|
|
||||||
item->printk = strdup(fmt);
|
item->printk = strdup(fmt);
|
||||||
item->addr = addr;
|
item->addr = addr;
|
||||||
|
|
||||||
|
if (!item->printk)
|
||||||
|
die("malloc fmt");
|
||||||
|
|
||||||
|
pevent->printklist = item;
|
||||||
pevent->printk_count++;
|
pevent->printk_count++;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2150,6 +2155,8 @@ process_fields(struct event_format *event, struct print_flag_sym **list, char **
|
||||||
if (value == NULL)
|
if (value == NULL)
|
||||||
goto out_free;
|
goto out_free;
|
||||||
field->value = strdup(value);
|
field->value = strdup(value);
|
||||||
|
if (field->value == NULL)
|
||||||
|
goto out_free;
|
||||||
|
|
||||||
free_arg(arg);
|
free_arg(arg);
|
||||||
arg = alloc_arg();
|
arg = alloc_arg();
|
||||||
|
@ -2163,6 +2170,8 @@ process_fields(struct event_format *event, struct print_flag_sym **list, char **
|
||||||
if (value == NULL)
|
if (value == NULL)
|
||||||
goto out_free;
|
goto out_free;
|
||||||
field->str = strdup(value);
|
field->str = strdup(value);
|
||||||
|
if (field->str == NULL)
|
||||||
|
goto out_free;
|
||||||
free_arg(arg);
|
free_arg(arg);
|
||||||
arg = NULL;
|
arg = NULL;
|
||||||
|
|
||||||
|
@ -3433,6 +3442,9 @@ process_defined_func(struct trace_seq *s, void *data, int size,
|
||||||
string = malloc_or_die(sizeof(*string));
|
string = malloc_or_die(sizeof(*string));
|
||||||
string->next = strings;
|
string->next = strings;
|
||||||
string->str = strdup(str.buffer);
|
string->str = strdup(str.buffer);
|
||||||
|
if (!string->str)
|
||||||
|
die("malloc str");
|
||||||
|
|
||||||
strings = string;
|
strings = string;
|
||||||
trace_seq_destroy(&str);
|
trace_seq_destroy(&str);
|
||||||
break;
|
break;
|
||||||
|
@ -3571,6 +3583,8 @@ static struct print_arg *make_bprint_args(char *fmt, void *data, int size, struc
|
||||||
arg->next = NULL;
|
arg->next = NULL;
|
||||||
arg->type = PRINT_BSTRING;
|
arg->type = PRINT_BSTRING;
|
||||||
arg->string.string = strdup(bptr);
|
arg->string.string = strdup(bptr);
|
||||||
|
if (!arg->string.string)
|
||||||
|
break;
|
||||||
bptr += strlen(bptr) + 1;
|
bptr += strlen(bptr) + 1;
|
||||||
*next = arg;
|
*next = arg;
|
||||||
next = &arg->next;
|
next = &arg->next;
|
||||||
|
@ -4666,6 +4680,8 @@ int pevent_parse_event(struct pevent *pevent,
|
||||||
die("failed to read event id");
|
die("failed to read event id");
|
||||||
|
|
||||||
event->system = strdup(sys);
|
event->system = strdup(sys);
|
||||||
|
if (!event->system)
|
||||||
|
die("failed to allocate system");
|
||||||
|
|
||||||
/* Add pevent to event so that it can be referenced */
|
/* Add pevent to event so that it can be referenced */
|
||||||
event->pevent = pevent;
|
event->pevent = pevent;
|
||||||
|
@ -4707,6 +4723,10 @@ int pevent_parse_event(struct pevent *pevent,
|
||||||
list = &arg->next;
|
list = &arg->next;
|
||||||
arg->type = PRINT_FIELD;
|
arg->type = PRINT_FIELD;
|
||||||
arg->field.name = strdup(field->name);
|
arg->field.name = strdup(field->name);
|
||||||
|
if (!arg->field.name) {
|
||||||
|
do_warning("failed to allocate field name");
|
||||||
|
goto event_failed;
|
||||||
|
}
|
||||||
arg->field.field = field;
|
arg->field.field = field;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -5050,6 +5070,11 @@ int pevent_register_event_handler(struct pevent *pevent,
|
||||||
if (sys_name)
|
if (sys_name)
|
||||||
handle->sys_name = strdup(sys_name);
|
handle->sys_name = strdup(sys_name);
|
||||||
|
|
||||||
|
if ((event_name && !handle->event_name) ||
|
||||||
|
(sys_name && !handle->sys_name)) {
|
||||||
|
die("Failed to allocate event/sys name");
|
||||||
|
}
|
||||||
|
|
||||||
handle->func = func;
|
handle->func = func;
|
||||||
handle->next = pevent->handlers;
|
handle->next = pevent->handlers;
|
||||||
pevent->handlers = handle;
|
pevent->handlers = handle;
|
||||||
|
|
Loading…
Add table
Reference in a new issue