From: Jérémie Galarneau Date: Mon, 9 Sep 2019 15:14:47 +0000 (-0400) Subject: Fix: uninitialized directory handle finalized on error path X-Git-Tag: v2.11.0-rc4~79 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=49f9e88d358c61f457d918555daf176222554133;p=lttng-tools.git Fix: uninitialized directory handle finalized on error path 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 --- 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; }