From 927617721d01b4a676356787f7792799e3c84223 Mon Sep 17 00:00:00 2001 From: Francis Deslauriers Date: Tue, 1 Oct 2019 11:43:39 -0400 Subject: [PATCH] Fix: relayd: Dereference after null check MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit There is no legitimate case where a stream's trace chunk would be NULL while receiving a data packet. It could only result from an internal error. Hence, stream->trace_chunk != NULL can be considered a pre-condition of this function. Coverity report: CID 1404937 (#1 of 1): Dereference after null check (FORWARD_NULL) 11. var_deref_model: Passing null pointer stream->index_file to relay_index_set_file, which dereferences it Reported-by: Coverity (1404937) Dereference after null check Signed-off-by: Francis Deslauriers Signed-off-by: Jérémie Galarneau --- src/bin/lttng-relayd/stream.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bin/lttng-relayd/stream.c b/src/bin/lttng-relayd/stream.c index 1b4e38ac8..3c61e3532 100644 --- a/src/bin/lttng-relayd/stream.c +++ b/src/bin/lttng-relayd/stream.c @@ -1052,6 +1052,7 @@ int stream_update_index(struct relay_stream *stream, uint64_t net_seq_num, uint64_t data_offset; struct relay_index *index; + assert(stream->trace_chunk); ASSERT_LOCKED(stream->lock); /* Get data offset because we are about to update the index. */ data_offset = htobe64(stream->tracefile_size_current); -- 2.34.1