Fix: dereference after null check in UST registry
authorDavid Goulet <dgoulet@efficios.com>
Thu, 28 Nov 2013 20:52:25 +0000 (15:52 -0500)
committerDavid Goulet <dgoulet@efficios.com>
Thu, 28 Nov 2013 20:52:25 +0000 (15:52 -0500)
Fix coverity issue 1132896.

Signed-off-by: David Goulet <dgoulet@efficios.com>
src/bin/lttng-sessiond/ust-registry.c

index 8c3d08d825c5568255ece6295d0b6be1dc2aa2a4..dc494161cd60ebedd6b55f19fd402458ca9b9fe7 100644 (file)
@@ -607,20 +607,25 @@ void ust_registry_session_destroy(struct ust_registry_session *reg)
        struct lttng_ht_iter iter;
        struct ust_registry_channel *chan;
 
+       assert(reg);
+
        /* On error, EBUSY can be returned if lock. Code flow error. */
        ret = pthread_mutex_destroy(&reg->lock);
        assert(!ret);
 
-       rcu_read_lock();
-       /* Destroy all event associated with this registry. */
-       cds_lfht_for_each_entry(reg->channels->ht, &iter.iter, chan, node.node) {
-               /* Delete the node from the ht and free it. */
-               ret = lttng_ht_del(reg->channels, &iter);
-               assert(!ret);
-               destroy_channel(chan);
+       if (reg->channels) {
+               rcu_read_lock();
+               /* Destroy all event associated with this registry. */
+               cds_lfht_for_each_entry(reg->channels->ht, &iter.iter, chan,
+                               node.node) {
+                       /* Delete the node from the ht and free it. */
+                       ret = lttng_ht_del(reg->channels, &iter);
+                       assert(!ret);
+                       destroy_channel(chan);
+               }
+               rcu_read_unlock();
+               ht_cleanup_push(reg->channels);
        }
-       rcu_read_unlock();
 
-       ht_cleanup_push(reg->channels);
        free(reg->metadata);
 }
This page took 0.026963 seconds and 4 git commands to generate.