mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] trace-cmd: record crashes if -f is used before -e event.
@ 2015-07-20 17:51 Daniel Bristot de Oliveira
  2015-11-17 23:57 ` John Kacur
  0 siblings, 1 reply; 3+ messages in thread
From: Daniel Bristot de Oliveira @ 2015-07-20 17:51 UTC (permalink / raw)
  To: Steven Rostedt; +Cc: LKML

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

Signed-off-by: Daniel Bristot de Oliveira <bristot@redhat.com>
---
 trace-record.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/trace-record.c b/trace-record.c
index 3e5def2..45826b6 100644
--- a/trace-record.c
+++ b/trace-record.c
@@ -2686,7 +2686,7 @@ void trace_record (int argc, char **argv)
 	const char *output = NULL;
 	const char *option;
 	struct event_list *event;
-	struct event_list *last_event;
+	struct event_list *last_event = NULL;
 	struct tracecmd_event_list *list;
 	struct buffer_instance *instance = &top_instance;
 	enum trace_type type;
-- 
2.1.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-07-15 19:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-20 17:51 [PATCH] trace-cmd: record crashes if -f is used before -e event Daniel Bristot de Oliveira
2015-11-17 23:57 ` John Kacur
2016-07-15 19:26   ` Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®