linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Arnaldo Carvalho de Melo <acme@infradead.org>
To: Ingo Molnar <mingo@kernel.org>
Cc: linux-kernel@vger.kernel.org, Namhyung Kim <namhyung.kim@lge.com>,
	Namhyung Kim <namhyung@kernel.org>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Peter Zijlstra <a.p.zijlstra@chello.nl>,
	Steven Rostedt <rostedt@goodmis.org>,
	Arnaldo Carvalho de Melo <acme@redhat.com>
Subject: [PATCH 03/13] tools lib traceevent: Get rid of die() from pevent_register_event_handler
Date: Fri,  7 Sep 2012 23:07:02 -0300	[thread overview]
Message-ID: <1347070032-4161-4-git-send-email-acme@infradead.org> (raw)
In-Reply-To: <1347070032-4161-1-git-send-email-acme@infradead.org>

From: Namhyung Kim <namhyung.kim@lge.com>

If memory allocation for handler fails, return gracefully instead of
calling die().  Note that casts to void * are needed because gcc
complained about discarding 'const' qualifier during implicit argument
cast.

Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Acked-by: Steven Rostedt <rostedt@goodmis.org>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Steven Rostedt <rostedt@goodmis.org>
Link: http://lkml.kernel.org/r/1346986187-5170-2-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/lib/traceevent/event-parse.c |   13 +++++++++++--
 1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index 6d5e759..17fd01d 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -5183,7 +5183,12 @@ int pevent_register_event_handler(struct pevent *pevent,
 
  not_found:
 	/* Save for later use. */
-	handle = malloc_or_die(sizeof(*handle));
+	handle = malloc(sizeof(*handle));
+	if (!handle) {
+		do_warning("Failed to allocate event handler");
+		return PEVENT_ERRNO__MEM_ALLOC_FAILED;
+	}
+
 	memset(handle, 0, sizeof(*handle));
 	handle->id = id;
 	if (event_name)
@@ -5193,7 +5198,11 @@ int pevent_register_event_handler(struct pevent *pevent,
 
 	if ((event_name && !handle->event_name) ||
 	    (sys_name && !handle->sys_name)) {
-		die("Failed to allocate event/sys name");
+		do_warning("Failed to allocate event/sys name");
+		free((void *)handle->event_name);
+		free((void *)handle->sys_name);
+		free(handle);
+		return PEVENT_ERRNO__MEM_ALLOC_FAILED;
 	}
 
 	handle->func = func;
-- 
1.7.9.2.358.g22243


  parent reply	other threads:[~2012-09-08  2:07 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-08  2:06 [GIT PULL 00/13] perf/core improvements and fixes Arnaldo Carvalho de Melo
2012-09-08  2:07 ` [PATCH 01/13] perf tools: Ignore compiled python binaries Arnaldo Carvalho de Melo
2012-09-08  2:07 ` [PATCH 02/13] tools lib traceevent: Get rid of die() from pretty_print() Arnaldo Carvalho de Melo
2012-09-08  2:07 ` Arnaldo Carvalho de Melo [this message]
2012-09-08  2:07 ` [PATCH 04/13] tools lib traceevent: Get rid of die() from pevent_register_print_function Arnaldo Carvalho de Melo
2012-09-08  2:07 ` [PATCH 05/13] perf diff: Make diff command work with evsel hists Arnaldo Carvalho de Melo
2012-09-08  2:07 ` [PATCH 06/13] perf tools: Replace sort's standalone field_sep with symbol_conf.field_sep Arnaldo Carvalho de Melo
2012-09-08  2:07 ` [PATCH 07/13] perf tools: include basename for non-glibc systems Arnaldo Carvalho de Melo
2012-09-08  2:07 ` [PATCH 08/13] perf tools: fix missing winsize definition Arnaldo Carvalho de Melo
2012-09-08  2:07 ` [PATCH 09/13] perf tools: include missing pthread.h header Arnaldo Carvalho de Melo
2012-09-08  2:07 ` [PATCH 10/13] perf tools: replace mkostemp with mkstemp Arnaldo Carvalho de Melo
2012-09-08  2:07 ` [PATCH 11/13] tools lib traceevent: replace mempcpy with memcpy Arnaldo Carvalho de Melo
2012-09-08  2:07 ` [PATCH 12/13] perf tools: add NO_BACKTRACE for application self-debugging Arnaldo Carvalho de Melo
2012-09-08  2:07 ` [PATCH 13/13] perf tools: Fix build for another rbtree.c change Arnaldo Carvalho de Melo
2012-09-08 11:28 ` [GIT PULL 00/13] perf/core improvements and fixes Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1347070032-4161-4-git-send-email-acme@infradead.org \
    --to=acme@infradead.org \
    --cc=a.p.zijlstra@chello.nl \
    --cc=acme@redhat.com \
    --cc=fweisbec@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@kernel.org \
    --cc=namhyung.kim@lge.com \
    --cc=namhyung@kernel.org \
    --cc=rostedt@goodmis.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).