From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758535AbcBTLlI (ORCPT ); Sat, 20 Feb 2016 06:41:08 -0500 Received: from terminus.zytor.com ([198.137.202.10]:38302 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758518AbcBTLlE (ORCPT ); Sat, 20 Feb 2016 06:41:04 -0500 Date: Sat, 20 Feb 2016 03:40:26 -0800 From: tip-bot for Namhyung Kim Message-ID: Cc: tglx@linutronix.de, linux-kernel@vger.kernel.org, jolsa@kernel.org, eranian@google.com, andi@firstfloor.org, hpa@zytor.com, fweisbec@gmail.com, namhyung@kernel.org, acme@redhat.com, peterz@infradead.org, wangnan0@huawei.com, dsahern@gmail.com, mingo@kernel.org Reply-To: eranian@google.com, jolsa@kernel.org, andi@firstfloor.org, hpa@zytor.com, fweisbec@gmail.com, namhyung@kernel.org, tglx@linutronix.de, linux-kernel@vger.kernel.org, dsahern@gmail.com, mingo@kernel.org, wangnan0@huawei.com, peterz@infradead.org, acme@redhat.com In-Reply-To: <1455631723-17345-6-git-send-email-namhyung@kernel.org> References: <1455631723-17345-6-git-send-email-namhyung@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf callchain: Check return value of split_add_child() Git-Commit-ID: f2bb4c5af4fe16d8b1e4ae371e1ceaa817380a88 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: f2bb4c5af4fe16d8b1e4ae371e1ceaa817380a88 Gitweb: http://git.kernel.org/tip/f2bb4c5af4fe16d8b1e4ae371e1ceaa817380a88 Author: Namhyung Kim AuthorDate: Tue, 16 Feb 2016 23:08:23 +0900 Committer: Arnaldo Carvalho de Melo CommitDate: Fri, 19 Feb 2016 19:14:36 -0300 perf callchain: Check return value of split_add_child() Now create_child() and add_child() return errors so check and pass it to the caller. Signed-off-by: Namhyung Kim Acked-by: Jiri Olsa Cc: Andi Kleen Cc: David Ahern Cc: Frederic Weisbecker Cc: Peter Zijlstra Cc: Stephane Eranian Cc: Wang Nan Link: http://lkml.kernel.org/r/1455631723-17345-6-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/callchain.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c index dab2c1f..5259379 100644 --- a/tools/perf/util/callchain.c +++ b/tools/perf/util/callchain.c @@ -508,7 +508,7 @@ static enum match_result match_chain(struct callchain_cursor_node *node, * give a part of its callchain to the created child. * Then create another child to host the given callchain of new branch */ -static void +static int split_add_child(struct callchain_node *parent, struct callchain_cursor *cursor, struct callchain_list *to_split, @@ -520,6 +520,8 @@ split_add_child(struct callchain_node *parent, /* split */ new = create_child(parent, true); + if (new == NULL) + return -1; /* split the callchain and move a part to the new child */ old_tail = parent->val.prev; @@ -554,7 +556,7 @@ split_add_child(struct callchain_node *parent, node = callchain_cursor_current(cursor); new = add_child(parent, cursor, period); if (new == NULL) - return; + return -1; /* * This is second child since we moved parent's children @@ -576,6 +578,7 @@ split_add_child(struct callchain_node *parent, parent->hit = period; parent->count = 1; } + return 0; } static enum match_result @@ -670,7 +673,10 @@ append_chain(struct callchain_node *root, /* we match only a part of the node. Split it and add the new chain */ if (matches < root->val_nr) { - split_add_child(root, cursor, cnode, start, matches, period); + if (split_add_child(root, cursor, cnode, start, matches, + period) < 0) + return MATCH_ERROR; + return MATCH_EQ; }