Skip to contentSkip to conversation

trace-cmd list: Check if any functions were found

PATCH New Steven Rostedt 1 participant 1 message Apr 4, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 trace-cmd list: Check if any functions were found

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

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()")
---
 tracecmd/trace-list.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tracecmd/trace-list.c +1 -1
index 8badd1f2..a441d136 100644
@@ -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);
 }
Signature · 1 line
2.47.2