Fix: tracepoint out of memory handling
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 21 Feb 2014 18:13:14 +0000 (13:13 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 21 Feb 2014 18:14:15 +0000 (13:14 -0500)
CID 1021247 (#1 of 1): Dereference null return value (NULL_RETURNS)3.
dereference: Dereferencing a null pointer "pl".

Handle more gracefully add_callsite memory allocation failure too.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
liblttng-ust/tracepoint.c

index 8c137a3892a99558d26ce4066db1c341e87639a4..00c471969b4394f16b9ec2e13bb520e10e78fe4b 100644 (file)
@@ -380,7 +380,10 @@ static void add_callsite(struct tracepoint_lib * lib, struct tracepoint *tp)
        hash = jhash(name, name_len, 0);
        head = &callsite_table[hash & (CALLSITE_TABLE_SIZE - 1)];
        e = zmalloc(sizeof(struct callsite_entry));
-       assert(e);
+       if (!e) {
+               PERROR("Unable to add callsite for tracepoint \"%s\"", name);
+               return;
+       }
        cds_hlist_add_head(&e->hlist, head);
        e->tp = tp;
        cds_list_add(&e->node, &lib->callsites);
@@ -729,7 +732,10 @@ int tracepoint_register_lib(struct tracepoint * const *tracepoints_start,
        init_tracepoint();
 
        pl = (struct tracepoint_lib *) zmalloc(sizeof(struct tracepoint_lib));
-
+       if (!pl) {
+               PERROR("Unable to register tracepoint lib");
+               return -1;
+       }
        pl->tracepoints_start = tracepoints_start;
        pl->tracepoints_count = tracepoints_count;
        CDS_INIT_LIST_HEAD(&pl->callsites);
This page took 0.025805 seconds and 4 git commands to generate.