aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/util/probe-finder.c
diff options
context:
space:
mode:
authorMasami Hiramatsu <mhiramat@redhat.com>2010-04-12 13:17:49 -0400
committerArnaldo Carvalho de Melo <acme@redhat.com>2010-04-14 16:28:45 -0400
commite334016f1d7250a6523b3a44ccecfe23af6e2f57 (patch)
tree376d8df547a43bd4288af2ec7ea4aa6aa6e8dd0e /tools/perf/util/probe-finder.c
parent146a143948ed9e8b248c0ec59937f3e9e1bbc7e5 (diff)
perf probe: Remove xzalloc() from util/probe-{event, finder}.c
Remove all xzalloc() calls from util/probe-{event,finder}.c since it may cause 'sudden death' in utility functions and it makes reusing it from other code difficult. Cc: Ingo Molnar <mingo@elte.hu> Cc: Paul Mackerras <paulus@samba.org> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Mike Galbraith <efault@gmx.de> Cc: Frederic Weisbecker <fweisbec@gmail.com> LKML-Reference: <20100412171749.3790.33303.stgit@localhost6.localdomain6> Signed-off-by: Masami Hiramatsu <mhiramat@redhat.com> Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/util/probe-finder.c')
-rw-r--r--tools/perf/util/probe-finder.c25
1 files changed, 18 insertions, 7 deletions
diff --git a/tools/perf/util/probe-finder.c b/tools/perf/util/probe-finder.c
index 54daa91e901d..ce1ac827f3d2 100644
--- a/tools/perf/util/probe-finder.c
+++ b/tools/perf/util/probe-finder.c
@@ -111,7 +111,7 @@ static int strtailcmp(const char *s1, const char *s2)
111/* Line number list operations */ 111/* Line number list operations */
112 112
113/* Add a line to line number list */ 113/* Add a line to line number list */
114static void line_list__add_line(struct list_head *head, unsigned int line) 114static int line_list__add_line(struct list_head *head, unsigned int line)
115{ 115{
116 struct line_node *ln; 116 struct line_node *ln;
117 struct list_head *p; 117 struct list_head *p;
@@ -122,16 +122,19 @@ static void line_list__add_line(struct list_head *head, unsigned int line)
122 p = &ln->list; 122 p = &ln->list;
123 goto found; 123 goto found;
124 } else if (ln->line == line) /* Already exist */ 124 } else if (ln->line == line) /* Already exist */
125 return ; 125 return 1;
126 } 126 }
127 /* List is empty, or the smallest entry */ 127 /* List is empty, or the smallest entry */
128 p = head; 128 p = head;
129found: 129found:
130 pr_debug("line list: add a line %u\n", line); 130 pr_debug("line list: add a line %u\n", line);
131 ln = xzalloc(sizeof(struct line_node)); 131 ln = zalloc(sizeof(struct line_node));
132 if (ln == NULL)
133 return -ENOMEM;
132 ln->line = line; 134 ln->line = line;
133 INIT_LIST_HEAD(&ln->list); 135 INIT_LIST_HEAD(&ln->list);
134 list_add(&ln->list, p); 136 list_add(&ln->list, p);
137 return 0;
135} 138}
136 139
137/* Check if the line in line number list */ 140/* Check if the line in line number list */
@@ -423,7 +426,9 @@ static int convert_location(Dwarf_Op *op, struct probe_finder *pf)
423 426
424 tvar->value = xstrdup(regs); 427 tvar->value = xstrdup(regs);
425 if (ref) { 428 if (ref) {
426 tvar->ref = xzalloc(sizeof(struct kprobe_trace_arg_ref)); 429 tvar->ref = zalloc(sizeof(struct kprobe_trace_arg_ref));
430 if (tvar->ref == NULL)
431 return -ENOMEM;
427 tvar->ref->offset = (long)offs; 432 tvar->ref->offset = (long)offs;
428 } 433 }
429 return 0; 434 return 0;
@@ -500,7 +505,9 @@ static int convert_variable_fields(Dwarf_Die *vr_die, const char *varname,
500 return -EINVAL; 505 return -EINVAL;
501 } 506 }
502 507
503 ref = xzalloc(sizeof(struct kprobe_trace_arg_ref)); 508 ref = zalloc(sizeof(struct kprobe_trace_arg_ref));
509 if (ref == NULL)
510 return -ENOMEM;
504 if (*ref_ptr) 511 if (*ref_ptr)
505 (*ref_ptr)->next = ref; 512 (*ref_ptr)->next = ref;
506 else 513 else
@@ -680,7 +687,9 @@ static int convert_probe_point(Dwarf_Die *sp_die, struct probe_finder *pf)
680 687
681 /* Find each argument */ 688 /* Find each argument */
682 tev->nargs = pf->pev->nargs; 689 tev->nargs = pf->pev->nargs;
683 tev->args = xzalloc(sizeof(struct kprobe_trace_arg) * tev->nargs); 690 tev->args = zalloc(sizeof(struct kprobe_trace_arg) * tev->nargs);
691 if (tev->args == NULL)
692 return -ENOMEM;
684 for (i = 0; i < pf->pev->nargs; i++) { 693 for (i = 0; i < pf->pev->nargs; i++) {
685 pf->pvar = &pf->pev->args[i]; 694 pf->pvar = &pf->pev->args[i];
686 pf->tvar = &tev->args[i]; 695 pf->tvar = &tev->args[i];
@@ -938,7 +947,9 @@ int find_kprobe_trace_events(int fd, struct perf_probe_event *pev,
938 Dwarf *dbg; 947 Dwarf *dbg;
939 int ret = 0; 948 int ret = 0;
940 949
941 pf.tevs = xzalloc(sizeof(struct kprobe_trace_event) * MAX_PROBES); 950 pf.tevs = zalloc(sizeof(struct kprobe_trace_event) * MAX_PROBES);
951 if (pf.tevs == NULL)
952 return -ENOMEM;
942 *tevs = pf.tevs; 953 *tevs = pf.tevs;
943 pf.ntevs = 0; 954 pf.ntevs = 0;
944 955