Fix: perform volatile load of tracepoint state
[lttng-ust.git] / liblttng-ust / tracepoint.c
index 8c137a3892a99558d26ce4066db1c341e87639a4..3404acf2e2272e2bd13bb9fcb2750d4157d99b49 100644 (file)
@@ -30,6 +30,7 @@
 #include <urcu/hlist.h>
 #include <urcu/uatomic.h>
 #include <urcu/compiler.h>
+#include <urcu/system.h>
 
 #include <lttng/tracepoint.h>
 #include <lttng/ust-abi.h>     /* for LTTNG_UST_SYM_NAME_LEN */
@@ -345,7 +346,7 @@ static void set_tracepoint(struct tracepoint_entry **entry,
         * is used.
         */
        rcu_assign_pointer(elem->probes, (*entry)->probes);
-       elem->state = active;
+       CMM_STORE_SHARED(elem->state, active);
 }
 
 /*
@@ -356,7 +357,7 @@ static void set_tracepoint(struct tracepoint_entry **entry,
  */
 static void disable_tracepoint(struct tracepoint *elem)
 {
-       elem->state = 0;
+       CMM_STORE_SHARED(elem->state, 0);
        rcu_assign_pointer(elem->probes, NULL);
 }
 
@@ -380,7 +381,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 +733,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.024504 seconds and 4 git commands to generate.