diff mbox series

trace-cmd list: Check if any functions were found

Message ID 20250404154949.6422bc8a@gandalf.local.home (mailing list archive)
State Accepted
Commit b44a9a9fc626b44ea4ea90a0bdec8e9924d77695
Headers show
Series trace-cmd list: Check if any functions were found | expand

Commit Message

Steven Rostedt April 4, 2025, 7:49 p.m. UTC
From: "Steven Rostedt (Google)" <rostedt@goodmis.org>

The trace-cmd list operation on functions will crash if no functions were
found:

  $ trace-cmd list -f aueaeu
  Segmentation fault

The list returned is NULL but the code still loops over the list of found
functions. Do not loop if no function is found.

Fixes: 39acb4cc1 ("trace-cmd list: Use tracefs_filter_functions()")
Signed-off-by: Steven Rostedt (Google) <rostedt@goodmis.org>
---
 tracecmd/trace-list.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/tracecmd/trace-list.c b/tracecmd/trace-list.c
index 8badd1f2..a441d136 100644
--- a/tracecmd/trace-list.c
+++ b/tracecmd/trace-list.c
@@ -476,7 +476,7 @@  static void show_functions(const char *funcre)
 
 	if (tracefs_filter_functions(funcre, NULL, &list) < 0)
 		die("Failed to read filte functions");
-	for (i = 0; list[i]; i++)
+	for (i = 0; list && list[i]; i++)
 		printf("%s\n", list[i]);
 	tracefs_list_free(list);
 }