diff mbox series

kernelshark: Release input_mutex on not finding record

Message ID 20220316112512.55e5b486@gandalf.local.home (mailing list archive)
State Accepted
Commit 37dd19f24c693e0c40a8cf133642e387b216540e
Headers show
Series kernelshark: Release input_mutex on not finding record | expand

Commit Message

Steven Rostedt March 16, 2022, 3:25 p.m. UTC
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

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")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 src/libkshark-tepdata.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/src/libkshark-tepdata.c b/src/libkshark-tepdata.c
index e9244b0761bb..08aca0989a59 100644
--- a/src/libkshark-tepdata.c
+++ b/src/libkshark-tepdata.c
@@ -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,