tracepoint: check if the probe has been registered
[linux-2.6.git] / kernel / tracepoint.c
index db39961..af8c856 100644 (file)
@@ -131,6 +131,9 @@ tracepoint_entry_remove_probe(struct tracepoint_entry *entry, void *probe)
 
        old = entry->funcs;
 
+       if (!old)
+               return NULL;
+
        debug_print_probes(entry);
        /* (N -> M), (N > 1, M >= 0) probes */
        for (nr_probes = 0; old[nr_probes]; nr_probes++) {
@@ -356,6 +359,8 @@ int tracepoint_probe_register(const char *name, void *probe)
        mutex_lock(&tracepoints_mutex);
        entry = get_tracepoint(name);
        WARN_ON(!entry);
+       if (entry->rcu_pending)
+               rcu_barrier_sched();
        tracepoint_entry_free_old(entry, old);
 end:
        mutex_unlock(&tracepoints_mutex);
@@ -386,12 +391,19 @@ int tracepoint_probe_unregister(const char *name, void *probe)
        if (entry->rcu_pending)
                rcu_barrier_sched();
        old = tracepoint_entry_remove_probe(entry, probe);
+       if (!old) {
+               printk(KERN_WARNING "Warning: Trying to unregister a probe"
+                                   "that doesn't exist\n");
+               goto end;
+       }
        mutex_unlock(&tracepoints_mutex);
        tracepoint_update_probes();             /* may update entry */
        mutex_lock(&tracepoints_mutex);
        entry = get_tracepoint(name);
        if (!entry)
                goto end;
+       if (entry->rcu_pending)
+               rcu_barrier_sched();
        tracepoint_entry_free_old(entry, old);
        remove_tracepoint(name);        /* Ignore busy error message */
        ret = 0;