Commit 7565bd39 authored by Namhyung Kim's avatar Namhyung Kim Committed by Arnaldo Carvalho de Melo

perf callchain: Check return value of add_child()

The create_child() in add_child() can return NULL in case of memory
allocation failure.  So check the return value and bail out.  The proper
error handling will be added later.
Signed-off-by: default avatarNamhyung Kim <namhyung@kernel.org>
Acked-by: default avatarJiri 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-3-git-send-email-namhyung@kernel.orgSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent 467ef10c
...@@ -453,6 +453,9 @@ add_child(struct callchain_node *parent, ...@@ -453,6 +453,9 @@ add_child(struct callchain_node *parent,
struct callchain_node *new; struct callchain_node *new;
new = create_child(parent, false); new = create_child(parent, false);
if (new == NULL)
return NULL;
fill_node(new, cursor); fill_node(new, cursor);
new->children_hit = 0; new->children_hit = 0;
...@@ -524,6 +527,8 @@ split_add_child(struct callchain_node *parent, ...@@ -524,6 +527,8 @@ split_add_child(struct callchain_node *parent,
node = callchain_cursor_current(cursor); node = callchain_cursor_current(cursor);
new = add_child(parent, cursor, period); new = add_child(parent, cursor, period);
if (new == NULL)
return;
/* /*
* This is second child since we moved parent's children * This is second child since we moved parent's children
...@@ -585,6 +590,9 @@ append_chain_children(struct callchain_node *root, ...@@ -585,6 +590,9 @@ append_chain_children(struct callchain_node *root,
} }
/* nothing in children, add to the current node */ /* nothing in children, add to the current node */
rnode = add_child(root, cursor, period); rnode = add_child(root, cursor, period);
if (rnode == NULL)
return;
rb_link_node(&rnode->rb_node_in, parent, p); rb_link_node(&rnode->rb_node_in, parent, p);
rb_insert_color(&rnode->rb_node_in, &root->rb_root_in); rb_insert_color(&rnode->rb_node_in, &root->rb_root_in);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment