linux-trace-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] libtracecmd: Return NULL if page is NULL in peek_last_event()
@ 2024-01-11 22:13 Steven Rostedt
  0 siblings, 0 replies; only message in thread
From: Steven Rostedt @ 2024-01-11 22:13 UTC (permalink / raw)
  To: Linux Trace Devel

From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

If the handle->cpu_data[cpu].page has been freed and cleared, consider the
last event to be empty. This can happen if the buffer size is zero.

 (Should we add a warning if page is NULL and size is not zero?)

Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 lib/trace-cmd/trace-input.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/lib/trace-cmd/trace-input.c b/lib/trace-cmd/trace-input.c
index f458dcec68a8..a10d74cf6cf4 100644
--- a/lib/trace-cmd/trace-input.c
+++ b/lib/trace-cmd/trace-input.c
@@ -2973,6 +2973,10 @@ static struct tep_record *peek_last_event(struct tracecmd_input *handle,
 	if (record)
 		return record;
 
+	/* page can be NULL if the size is zero */
+	if (!page)
+		return NULL;
+
 	page_offset = page->offset - handle->page_size;
 	if (page_offset < handle->cpu_data[cpu].file_offset)
 		return NULL;
-- 
2.43.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2024-01-11 22:12 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-01-11 22:13 [PATCH] libtracecmd: Return NULL if page is NULL in peek_last_event() Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).