From: Jérémie Galarneau Date: Thu, 30 Jul 2020 16:14:21 +0000 (-0400) Subject: Fix: relayd: double unlock on viewer stream creation error X-Git-Tag: v2.13.0-rc1~555 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=71381736573d0779956f4a0bc7d206acc98cd3cb;p=lttng-tools.git Fix: relayd: double unlock on viewer stream creation error viewer_stream_create must be called with the relay stream's lock held since 9edaf114d. A call to pthread_mutex_unlock was forgotten in the error path of viewer_stream_create resulting in a double-unlock in some error scenarios. Signed-off-by: Jérémie Galarneau Change-Id: I613f67440669af52f625b7bdc4e9ae6ce75956ea --- diff --git a/src/bin/lttng-relayd/viewer-stream.c b/src/bin/lttng-relayd/viewer-stream.c index f07e062f8..511eaad93 100644 --- a/src/bin/lttng-relayd/viewer-stream.c +++ b/src/bin/lttng-relayd/viewer-stream.c @@ -75,7 +75,7 @@ struct relay_viewer_stream *viewer_stream_create(struct relay_stream *stream, if (stream->is_metadata && stream->trace->viewer_metadata_stream) { ERR("Cannot attach viewer metadata stream to trace (busy)."); - goto error_unlock; + goto error; } switch (seek_t) { @@ -110,7 +110,7 @@ struct relay_viewer_stream *viewer_stream_create(struct relay_stream *stream, tracefile_array_get_seq_head(stream->tfa) + 1; break; default: - goto error_unlock; + goto error; } /* @@ -138,7 +138,7 @@ struct relay_viewer_stream *viewer_stream_create(struct relay_stream *stream, if (chunk_status == LTTNG_TRACE_CHUNK_STATUS_NO_FILE) { vstream->index_file = NULL; } else { - goto error_unlock; + goto error; } } } @@ -157,7 +157,7 @@ struct relay_viewer_stream *viewer_stream_create(struct relay_stream *stream, vstream->current_tracefile_id, NULL, file_path, sizeof(file_path)); if (ret < 0) { - goto error_unlock; + goto error; } status = lttng_trace_chunk_open_fs_handle( @@ -165,7 +165,7 @@ struct relay_viewer_stream *viewer_stream_create(struct relay_stream *stream, O_RDONLY, 0, &vstream->stream_file.handle, true); if (status != LTTNG_TRACE_CHUNK_STATUS_OK) { - goto error_unlock; + goto error; } } @@ -175,7 +175,7 @@ struct relay_viewer_stream *viewer_stream_create(struct relay_stream *stream, lseek_ret = fs_handle_seek( vstream->index_file->file, 0, SEEK_END); if (lseek_ret < 0) { - goto error_unlock; + goto error; } } if (stream->is_metadata) { @@ -190,8 +190,6 @@ struct relay_viewer_stream *viewer_stream_create(struct relay_stream *stream, return vstream; -error_unlock: - pthread_mutex_unlock(&stream->lock); error: if (vstream) { viewer_stream_destroy(vstream);