[PATCH] libtraceevent: Return error on event parsing if format parsing fails

Steven Rostedt <[email protected]> Thu, 9 Jan 2025 10:23:38 -0500
Newsgroups org.kernel.vger.linux-trace-devel
Message-ID <[email protected]>
From: "Steven Rostedt (Google)" <[email protected]>

The event parsing should not fail if the "print fmt" portion fails, as
that is just a hint by the kernel on how to display the event. But that
portion can contain kernel internal information that is not available to
user space and there's no way the library can parse it properly. When that
fails, the event printing falls back to simply showing the content of all
the fields.

But if the fields themselves fail to parse, then there's no way to parse
the event properly. This should end up as a failure of parsing the event.

Link: https://lore.kernel.org/all/[email protected]/

Reported-by: Shiju Jose <[email protected]>
Signed-off-by: Steven Rostedt (Google) <[email protected]>
---
 src/event-parse.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/event-parse.c b/src/event-parse.c
index 33ed7fb47fff..f2e50b0e8992 100644
--- a/src/event-parse.c
+++ b/src/event-parse.c
@@ -7841,7 +7841,7 @@ static enum tep_errno parse_format(struct tep_event **eventp,
 	ret = event_read_format(event);
 	if (ret < 0) {
 		ret = TEP_ERRNO__READ_FORMAT_FAILED;
-		goto event_parse_failed;
+		goto event_alloc_failed;
 	}
 
 	/*
-- 
2.45.2