From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1758447AbcBTLkU (ORCPT ); Sat, 20 Feb 2016 06:40:20 -0500 Received: from terminus.zytor.com ([198.137.202.10]:38265 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758430AbcBTLkQ (ORCPT ); Sat, 20 Feb 2016 06:40:16 -0500 Date: Sat, 20 Feb 2016 03:39:24 -0800 From: tip-bot for Namhyung Kim Message-ID: Cc: tglx@linutronix.de, hpa@zytor.com, eranian@google.com, dsahern@gmail.com, jolsa@kernel.org, namhyung@kernel.org, wangnan0@huawei.com, fweisbec@gmail.com, mingo@kernel.org, andi@firstfloor.org, linux-kernel@vger.kernel.org, acme@redhat.com, peterz@infradead.org Reply-To: tglx@linutronix.de, dsahern@gmail.com, eranian@google.com, hpa@zytor.com, namhyung@kernel.org, jolsa@kernel.org, fweisbec@gmail.com, wangnan0@huawei.com, mingo@kernel.org, andi@firstfloor.org, linux-kernel@vger.kernel.org, peterz@infradead.org, acme@redhat.com In-Reply-To: <1455631723-17345-3-git-send-email-namhyung@kernel.org> References: <1455631723-17345-3-git-send-email-namhyung@kernel.org> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf callchain: Check return value of add_child() Git-Commit-ID: 7565bd39c1a63c82350d26a66ea1a1f1bb49ad2e 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: 7565bd39c1a63c82350d26a66ea1a1f1bb49ad2e Gitweb: http://git.kernel.org/tip/7565bd39c1a63c82350d26a66ea1a1f1bb49ad2e Author: Namhyung Kim AuthorDate: Tue, 16 Feb 2016 23:08:20 +0900 Committer: Arnaldo Carvalho de Melo CommitDate: Fri, 19 Feb 2016 19:12:52 -0300 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: 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-3-git-send-email-namhyung@kernel.org Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/util/callchain.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/perf/util/callchain.c b/tools/perf/util/callchain.c index 53c43eb..134d88b 100644 --- a/tools/perf/util/callchain.c +++ b/tools/perf/util/callchain.c @@ -453,6 +453,9 @@ add_child(struct callchain_node *parent, struct callchain_node *new; new = create_child(parent, false); + if (new == NULL) + return NULL; + fill_node(new, cursor); new->children_hit = 0; @@ -524,6 +527,8 @@ split_add_child(struct callchain_node *parent, node = callchain_cursor_current(cursor); new = add_child(parent, cursor, period); + if (new == NULL) + return; /* * This is second child since we moved parent's children @@ -585,6 +590,9 @@ append_chain_children(struct callchain_node *root, } /* nothing in children, add to the current node */ rnode = add_child(root, cursor, period); + if (rnode == NULL) + return; + rb_link_node(&rnode->rb_node_in, parent, p); rb_insert_color(&rnode->rb_node_in, &root->rb_root_in);