From: David Goulet Date: Thu, 28 Nov 2013 20:52:25 +0000 (-0500) Subject: Fix: dereference after null check in UST registry X-Git-Tag: v2.4.0-rc2~12 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=9d8efb0ed1d06ea73d77b8a0539b67d1e0dc501b;p=lttng-tools.git Fix: dereference after null check in UST registry Fix coverity issue 1132896. Signed-off-by: David Goulet --- diff --git a/src/bin/lttng-sessiond/ust-registry.c b/src/bin/lttng-sessiond/ust-registry.c index 8c3d08d82..dc494161c 100644 --- a/src/bin/lttng-sessiond/ust-registry.c +++ b/src/bin/lttng-sessiond/ust-registry.c @@ -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(®->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); }