aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Bristot de Oliveira <bristot@redhat.com>2015-07-20 14:51:00 -0300
committerSteven Rostedt <rostedt@goodmis.org>2016-07-15 15:23:37 -0400
commitfca725695474085397339abe07de4a91a781269e (patch)
treee4ecd2c68e3d45c884815368c05f357511299c1d
parent65ffbd349250575d0549841f0517bd64d7084a0e (diff)
downloadtrace-cmd-fca725695474085397339abe07de4a91a781269e.tar.gz
trace-cmd: record crashes if -f is used before -e event.
The trace-cmd record command is crashing if a -f filter is used before a -e event. The usage a -f before a -e is a command line error, and trace-cmd record detects this error by checking if the last_event pointer is NULL. However, the last_event is not initialized as NULL and this command line error is not detected. Then, the last_event is used to save the filter options and this causes a segmentation fault because last_event was not initialized yet. This problem is fixed by initializing last_event as NULL. How-to reproduce: # trace-cmd record -f foo Segmentation fault Expected output: # trace-cmd record -f foo filter must come after event Link: http://lkml.kernel.org/r/894eb6c8a5665fba64811395e0d1204e201f4992.1437414265.git.bristot@redhat.com Tested-by: John Kacur <jkacur@redhat.com> Signed-off-by: Daniel Bristot de Oliveira <bristot@redhat.com> Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
-rw-r--r--trace-record.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/trace-record.c b/trace-record.c
index fc124b7f..22b6835c 100644
--- a/trace-record.c
+++ b/trace-record.c
@@ -4131,7 +4131,7 @@ void trace_record (int argc, char **argv)
const char *output = NULL;
const char *option;
struct event_list *event = NULL;
- struct event_list *last_event;
+ struct event_list *last_event = NULL;
struct buffer_instance *instance = &top_instance;
enum trace_type type = 0;
char *pids;