From d6297168f9042cdc550507bb5e97cee7037c34d3 Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Fri, 21 Feb 2014 13:13:14 -0500 Subject: [PATCH] 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 --- liblttng-ust/tracepoint.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) 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); -- 2.34.1