X-Git-Url: https://git.lttng.org/?a=blobdiff_plain;f=src%2Fbin%2Flttng-sessiond%2Fust-registry.c;h=1a00e9349fb2f04c6052a5222acaf7d927fdd471;hb=ce34fcd0419afa029cec4a093a96d81e3c338eea;hp=65ba82c1b99b16bb51991161bc32f42dafcadcae;hpb=8494bda55cb1a09f5db0b57968fc3e84bd2981ea;p=lttng-tools.git diff --git a/src/bin/lttng-sessiond/ust-registry.c b/src/bin/lttng-sessiond/ust-registry.c index 65ba82c1b..1a00e9349 100644 --- a/src/bin/lttng-sessiond/ust-registry.c +++ b/src/bin/lttng-sessiond/ust-registry.c @@ -15,6 +15,7 @@ * Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ #define _GNU_SOURCE +#define _LGPL_SOURCE #include #include @@ -592,6 +593,7 @@ int ust_registry_session_init(struct ust_registry_session **sessionp, error: ust_registry_session_destroy(session); + free(session); error_alloc: return -1; } @@ -606,20 +608,27 @@ void ust_registry_session_destroy(struct ust_registry_session *reg) struct lttng_ht_iter iter; struct ust_registry_channel *chan; + if (!reg) { + return; + } + /* 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); }