From 0ccc041129a301ccfea4624755d21fbd2e2625de Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Mon, 9 Sep 2019 11:14:47 -0400 Subject: [PATCH] Fix: uninitialized directory handle finalized on error path MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit relay_create_trace_chunk() creates a session output directory handle and assigns it to a trace chunk. Since a handle doesn't have a dedicated "uninitialized" state, reduce its lifetime and don't generically finalize it in error paths. Signed-off-by: Jérémie Galarneau --- src/bin/lttng-relayd/main.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/bin/lttng-relayd/main.c b/src/bin/lttng-relayd/main.c index 431a0d67a..8e67f7664 100644 --- a/src/bin/lttng-relayd/main.c +++ b/src/bin/lttng-relayd/main.c @@ -2386,13 +2386,6 @@ static int relay_create_trace_chunk(const struct lttcomm_relayd_hdr *recv_hdr, } } - ret = session_init_output_directory_handle( - conn->session, &session_output); - if (ret) { - reply_code = LTTNG_ERR_CREATE_DIR_FAIL; - goto end; - } - chunk_status = lttng_trace_chunk_set_credentials_current_user(chunk); if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) { reply_code = LTTNG_ERR_UNK; @@ -2400,7 +2393,14 @@ static int relay_create_trace_chunk(const struct lttcomm_relayd_hdr *recv_hdr, goto end; } + ret = session_init_output_directory_handle( + conn->session, &session_output); + if (ret) { + reply_code = LTTNG_ERR_CREATE_DIR_FAIL; + goto end; + } chunk_status = lttng_trace_chunk_set_as_owner(chunk, &session_output); + lttng_directory_handle_fini(&session_output); if (chunk_status != LTTNG_TRACE_CHUNK_STATUS_OK) { reply_code = LTTNG_ERR_UNK; ret = -1; @@ -2456,7 +2456,6 @@ end: end_no_reply: lttng_trace_chunk_put(chunk); lttng_trace_chunk_put(published_chunk); - lttng_directory_handle_fini(&session_output); return ret; } -- 2.34.1