mirror of
https://github.com/torvalds/linux.git
synced 2024-12-03 17:41:22 +00:00
perf callchain: Check return value of fill_node()
Memory allocation in the fill_node() can fail so change its return type to int and check it in add_child() too. Signed-off-by: Namhyung Kim <namhyung@kernel.org> Acked-by: Jiri Olsa <jolsa@kernel.org> Cc: Andi Kleen <andi@firstfloor.org> Cc: David Ahern <dsahern@gmail.com> Cc: Frederic Weisbecker <fweisbec@gmail.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Stephane Eranian <eranian@google.com> Cc: Wang Nan <wangnan0@huawei.com> Link: http://lkml.kernel.org/r/1455631723-17345-4-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
parent
7565bd39c1
commit
8451cbb9b1
@ -416,7 +416,7 @@ create_child(struct callchain_node *parent, bool inherit_children)
|
||||
/*
|
||||
* Fill the node with callchain values
|
||||
*/
|
||||
static void
|
||||
static int
|
||||
fill_node(struct callchain_node *node, struct callchain_cursor *cursor)
|
||||
{
|
||||
struct callchain_cursor_node *cursor_node;
|
||||
@ -433,7 +433,7 @@ fill_node(struct callchain_node *node, struct callchain_cursor *cursor)
|
||||
call = zalloc(sizeof(*call));
|
||||
if (!call) {
|
||||
perror("not enough memory for the code path tree");
|
||||
return;
|
||||
return -1;
|
||||
}
|
||||
call->ip = cursor_node->ip;
|
||||
call->ms.sym = cursor_node->sym;
|
||||
@ -443,6 +443,7 @@ fill_node(struct callchain_node *node, struct callchain_cursor *cursor)
|
||||
callchain_cursor_advance(cursor);
|
||||
cursor_node = callchain_cursor_current(cursor);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct callchain_node *
|
||||
@ -456,7 +457,16 @@ add_child(struct callchain_node *parent,
|
||||
if (new == NULL)
|
||||
return NULL;
|
||||
|
||||
fill_node(new, cursor);
|
||||
if (fill_node(new, cursor) < 0) {
|
||||
struct callchain_list *call, *tmp;
|
||||
|
||||
list_for_each_entry_safe(call, tmp, &new->val, list) {
|
||||
list_del(&call->list);
|
||||
free(call);
|
||||
}
|
||||
free(new);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
new->children_hit = 0;
|
||||
new->hit = period;
|
||||
|
Loading…
Reference in New Issue
Block a user