From: Mathieu Desnoyers Date: Fri, 21 Feb 2014 18:13:14 +0000 (-0500) Subject: Fix: tracepoint out of memory handling X-Git-Tag: v2.3.2~4 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=9e9a9433164231ca4ab8849235d2d0399fa7efe5;p=lttng-ust.git Fix: tracepoint out of memory handling 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 --- diff --git a/liblttng-ust/tracepoint.c b/liblttng-ust/tracepoint.c index 8c137a38..00c47196 100644 --- a/liblttng-ust/tracepoint.c +++ b/liblttng-ust/tracepoint.c @@ -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);