From: Jiri Olsa <jolsa@redhat.com>
To: Namhyung Kim <namhyung@kernel.org>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
Corey Ashford <cjashfor@linux.vnet.ibm.com>,
Frederic Weisbecker <fweisbec@gmail.com>,
Ingo Molnar <mingo@elte.hu>, Paul Mackerras <paulus@samba.org>,
Peter Zijlstra <a.p.zijlstra@chello.nl>,
Arnaldo Carvalho de Melo <acme@ghostprotocols.net>,
Steven Rostedt <rostedt@goodmis.org>,
David Ahern <dsahern@gmail.com>
Subject: [PATCHv3 20/29] tools lib traceevent: Remove malloc_or_die from plugin_function.c
Date: Fri, 29 Nov 2013 13:42:49 +0100 [thread overview]
Message-ID: <20131129124249.GF1231@krava.brq.redhat.com> (raw)
In-Reply-To: <CAM9d7cj2T-AP45ZSy+Q+_cGzHcm+sr7wpPD4Nu-Ud316hpFHDQ@mail.gmail.com>
On Fri, Nov 29, 2013 at 10:54:21AM +0000, Namhyung Kim wrote:
> > Removing malloc_or_die calls from plugin_function.c,
> > replacing them and factoring the code with standard
> > realloc and error path.
>
> [SNIP]
> >
> > if (cpu > cpus) {
> > - if (fstack)
> > - fstack = realloc(fstack, sizeof(*fstack) * (cpu + 1));
> > - else
> > - fstack = malloc_or_die(sizeof(*fstack) * (cpu + 1));
> > + fstack = realloc(fstack, sizeof(*fstack) * (cpu + 1));
>
> This code also has same problem..
>
and v3.1 ;-) thanks
jirka
---
Removing malloc_or_die calls from plugin_function.c,
replacing them and factoring the code with standard
realloc and error path.
Suggested-by: Namhyung Kim <namhyung@kernel.org>
Signed-off-by: Jiri Olsa <jolsa@redhat.com>
Cc: Corey Ashford <cjashfor@linux.vnet.ibm.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: David Ahern <dsahern@gmail.com>
---
tools/lib/traceevent/plugin_function.c | 29 ++++++++++++++++++++---------
1 file changed, 20 insertions(+), 9 deletions(-)
diff --git a/tools/lib/traceevent/plugin_function.c b/tools/lib/traceevent/plugin_function.c
index 87acf9c..aad92ad 100644
--- a/tools/lib/traceevent/plugin_function.c
+++ b/tools/lib/traceevent/plugin_function.c
@@ -43,11 +43,17 @@ static void add_child(struct func_stack *stack, const char *child, int pos)
if (pos < stack->size)
free(stack->stack[pos]);
else {
- if (!stack->stack)
- stack->stack = malloc_or_die(sizeof(char *) * STK_BLK);
- else
- stack->stack = realloc(stack->stack, sizeof(char *) *
- (stack->size + STK_BLK));
+ char **ptr;
+
+ ptr = realloc(stack->stack, sizeof(char *) *
+ (stack->size + STK_BLK));
+ if (!ptr) {
+ warning("could not allocate plugin memory\n");
+ return;
+ }
+
+ stack->stack = ptr;
+
for (i = stack->size; i < stack->size + STK_BLK; i++)
stack->stack[i] = NULL;
stack->size += STK_BLK;
@@ -64,10 +70,15 @@ static int add_and_get_index(const char *parent, const char *child, int cpu)
return 0;
if (cpu > cpus) {
- if (fstack)
- fstack = realloc(fstack, sizeof(*fstack) * (cpu + 1));
- else
- fstack = malloc_or_die(sizeof(*fstack) * (cpu + 1));
+ struct func_stack *ptr;
+
+ ptr = realloc(fstack, sizeof(*fstack) * (cpu + 1));
+ if (!ptr) {
+ warning("could not allocate plugin memory\n");
+ return 0;
+ }
+
+ fstack = ptr;
/* Account for holes in the cpu count */
for (i = cpus + 1; i <= cpu; i++)
--
1.8.3.1
next prev parent reply other threads:[~2013-11-29 12:43 UTC|newest]
Thread overview: 45+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-28 11:32 [PATCHv2 00/27] perf tools: Add traceevent plugins support Jiri Olsa
2013-11-28 11:33 ` [PATCH 01/29] perf tools: Remove stackprotector feature check Jiri Olsa
2013-11-29 18:34 ` Arnaldo Carvalho de Melo
2013-11-30 16:46 ` [PATCHv3 " Jiri Olsa
2013-12-01 12:21 ` Ingo Molnar
2013-11-28 11:33 ` [PATCH 02/29] perf tools: Include test-stackprotector-all.c in test-all Jiri Olsa
2013-12-04 15:41 ` [tip:perf/core] " tip-bot for Jiri Olsa
2013-11-28 11:33 ` [PATCH 03/29] tools lib traceevent: Add plugin support Jiri Olsa
2013-11-28 11:33 ` [PATCH 04/29] tools lib traceevent: Add plugin build support Jiri Olsa
2013-11-28 11:33 ` [PATCH 05/29] tools lib traceevent: Add traceevent_host_bigendian function Jiri Olsa
2013-11-28 11:33 ` [PATCH 06/29] tools lib traceevent: Add jbd2 plugin Jiri Olsa
2013-11-29 18:42 ` Arnaldo Carvalho de Melo
2013-11-29 19:31 ` Arnaldo Carvalho de Melo
2013-11-30 16:49 ` Jiri Olsa
2013-12-02 19:26 ` Arnaldo Carvalho de Melo
2013-12-02 19:31 ` Jiri Olsa
2013-11-30 16:46 ` Jiri Olsa
2013-11-28 11:33 ` [PATCH 07/29] tools lib traceevent: Add hrtimer plugin Jiri Olsa
2013-11-28 11:33 ` [PATCH 08/29] tools lib traceevent: Add kmem plugin Jiri Olsa
2013-11-28 11:33 ` [PATCH 09/29] tools lib traceevent: Add kvm plugin Jiri Olsa
2013-11-28 11:33 ` [PATCH 10/29] tools lib traceevent: Add mac80211 plugin Jiri Olsa
2013-11-28 11:33 ` [PATCH 11/29] tools lib traceevent: Add sched_switch plugin Jiri Olsa
2013-11-28 11:33 ` [PATCH 12/29] tools lib traceevent: Add function plugin Jiri Olsa
2013-11-28 11:33 ` [PATCH 13/29] tools lib traceevent: Add xen plugin Jiri Olsa
2013-11-28 11:33 ` [PATCH 14/29] tools lib traceevent: Add scsi plugin Jiri Olsa
2013-11-28 11:33 ` [PATCH 15/29] tools lib traceevent: Add cfg80211 plugin Jiri Olsa
2013-11-28 11:33 ` [PATCH 16/29] tools lib traceevent: Remove malloc_or_die from event-plugin.c Jiri Olsa
2013-11-28 11:33 ` [PATCH 17/29] tools lib traceevent: Use static functions in jbd2 plugin Jiri Olsa
2013-11-28 11:33 ` [PATCH 18/29] tools lib traceevent: Use pevent_print_func_field in hrtimer_start handler Jiri Olsa
2013-11-28 11:33 ` [PATCH 19/29] tools lib traceevent: Several cleanups for function plugin Jiri Olsa
2013-11-28 11:33 ` [PATCH 20/29] tools lib traceevent: Remove malloc_or_die from plugin_function.c Jiri Olsa
2013-11-29 6:41 ` Namhyung Kim
2013-11-29 10:37 ` [PATCHv3 " Jiri Olsa
2013-11-29 10:54 ` Namhyung Kim
2013-11-29 12:42 ` Jiri Olsa [this message]
2013-12-02 8:29 ` Namhyung Kim
2013-11-28 11:33 ` [PATCH 21/29] tools lib traceevent: Update kvm plugin with is_writable_pte helper Jiri Olsa
2013-11-28 11:33 ` [PATCH 22/29] tools lib traceevent: Change pevent_parse_format to include pevent handle Jiri Olsa
2013-11-28 11:33 ` [PATCH 23/29] tools lib traceevent: Harmonize the install messages in lib-traceevent Jiri Olsa
2013-11-28 11:33 ` [PATCH 24/29] perf tools: Add build and install plugins targets Jiri Olsa
2013-11-28 11:33 ` [PATCH 25/29] perf tools: Add udis86 disassembler feature check Jiri Olsa
2013-11-28 11:33 ` [PATCH 26/29] perf tools: Add filename__read_str util function Jiri Olsa
2013-11-28 11:33 ` [PATCH 27/29] perf tools: Add trace-event object Jiri Olsa
2013-11-28 11:33 ` [PATCH 28/29] perf tools: Add trace-event global object for tracepoint interface Jiri Olsa
2013-11-28 11:33 ` [PATCH 29/29] perf tools: Overload pr_stat traceevent print function Jiri Olsa
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=20131129124249.GF1231@krava.brq.redhat.com \
--to=jolsa@redhat.com \
--cc=a.p.zijlstra@chello.nl \
--cc=acme@ghostprotocols.net \
--cc=cjashfor@linux.vnet.ibm.com \
--cc=dsahern@gmail.com \
--cc=fweisbec@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
--cc=namhyung@kernel.org \
--cc=paulus@samba.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
Powered by JetHome