trace-cmd list: Check if any functions were found
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()")
Signed-off-by Steven Rostedt (Google) <[email protected]>
--- tracecmd/trace-list.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tracecmd/trace-list.c +1 -1
@@ -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