From 0eafad74c0d00bf2723ed88320e1c2d8393dab5a Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Fri, 16 Oct 2020 08:25:10 -0400 Subject: [PATCH] relayd: silence null dereference warning during viewer stream creation MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Coverity warns that the vstream's trace chunk may be used NULL. However, this won't happen if the corresponding relay stream has an active trace chunk. Coverity report: 1433620 Dereference after null check Either the check against null is unnecessary, or there may be a null pointer dereference. In viewer_stream_create: Pointer is checked against null but then dereferenced anyway (CWE-476) Reported-by: Coverity Scan Signed-off-by: Jérémie Galarneau Change-Id: Ie032ed415a99cfff149e3325d05f37ededb52d33 --- src/bin/lttng-relayd/viewer-stream.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/bin/lttng-relayd/viewer-stream.c b/src/bin/lttng-relayd/viewer-stream.c index 67c452eec..00616569b 100644 --- a/src/bin/lttng-relayd/viewer-stream.c +++ b/src/bin/lttng-relayd/viewer-stream.c @@ -122,7 +122,7 @@ struct relay_viewer_stream *viewer_stream_create(struct relay_stream *stream, */ if (stream->index_file == NULL) { vstream->index_file = NULL; - } else { + } else if (vstream->stream_file.trace_chunk) { const uint32_t connection_major = stream->trace->session->major; const uint32_t connection_minor = stream->trace->session->minor; enum lttng_trace_chunk_status chunk_status; @@ -150,7 +150,7 @@ struct relay_viewer_stream *viewer_stream_create(struct relay_stream *stream, * If we never received a data file for the current stream, delay the * opening, otherwise open it right now. */ - if (stream->file) { + if (stream->file && vstream->stream_file.trace_chunk) { int ret; char file_path[LTTNG_PATH_MAX]; enum lttng_trace_chunk_status status; -- 2.34.1