Skip to contentSkip to conversation

kernelshark: Release input_mutex on not finding record

PATCH New Steven Rostedt 1 participant 1 message Mar 16, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 kernelshark: Release input_mutex on not finding record

From: "Steven Rostedt (Google)" <[email protected]>

The tepdata_get_latency() function could exit without releasing the stream->input_mutex, which would cause a lockup later on.

Fixes 836ce858246b7 ("kernel-shark: Add stream interface for trace-cmd data")
---
 src/libkshark-tepdata.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
src/libkshark-tepdata.c +3 -1
index e9244b0761bb..08aca0989a59 100644
@@ -793,8 +793,10 @@ static char *tepdata_get_latency(struct kshark_data_stream *stream,
 
 	record = tracecmd_read_at(kshark_get_tep_input(stream), entry->offset, NULL);
 
-	if (!record)
+	if (!record) {
+		pthread_mutex_unlock(&stream->input_mutex);
 		return NULL;
+	}
 
 	trace_seq_reset(&seq);
 	tep_print_event(kshark_get_tep(stream), &seq, record,
Signature · 1 line
2.35.1