From e441f4e920a6be99434617c7489cb289f9cf7f22 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Mon, 9 Sep 2019 10:53:45 -0400 Subject: [PATCH] Fix: destroy chunk registry on element creation failure MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit A failure path in trace_chunk_registry_ht_element_create() does not destroy a newly created chunk registry, resulting in a leak. The ownership of the registry is transfered to the element being created as soon as possible. Error paths that release the reference on the new element will then naturally clean-up the trace chunk registry. Signed-off-by: Jérémie Galarneau --- src/bin/lttng-relayd/sessiond-trace-chunks.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/bin/lttng-relayd/sessiond-trace-chunks.c b/src/bin/lttng-relayd/sessiond-trace-chunks.c index 01d5b3c2d..e7a7d112d 100644 --- a/src/bin/lttng-relayd/sessiond-trace-chunks.c +++ b/src/bin/lttng-relayd/sessiond-trace-chunks.c @@ -213,6 +213,7 @@ int trace_chunk_registry_ht_element_create( urcu_ref_init(&new_element->ref); cds_lfht_node_init(&new_element->ht_node); new_element->trace_chunk_registry = trace_chunk_registry; + trace_chunk_registry = NULL; /* Attempt to publish the new element. */ rcu_read_lock(); @@ -261,6 +262,7 @@ end: ERR("Failed to create trace chunk registry for session daemon {%s}", uuid_str); } + lttng_trace_chunk_registry_destroy(trace_chunk_registry); return ret; } -- 2.34.1