Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755044AbbKQX5T (ORCPT ); Tue, 17 Nov 2015 18:57:19 -0500 Received: from mail-wm0-f45.google.com ([74.125.82.45]:33156 "EHLO mail-wm0-f45.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754957AbbKQX5R (ORCPT ); Tue, 17 Nov 2015 18:57:17 -0500 Date: Wed, 18 Nov 2015 00:57:14 +0100 (CET) From: John Kacur X-X-Sender: jkacur@riemann To: Daniel Bristot de Oliveira cc: Steven Rostedt , LKML Subject: Re: [PATCH] trace-cmd: record crashes if -f is used before -e event. In-Reply-To: <894eb6c8a5665fba64811395e0d1204e201f4992.1437414265.git.bristot@redhat.com> Message-ID: References: <894eb6c8a5665fba64811395e0d1204e201f4992.1437414265.git.bristot@redhat.com> User-Agent: Alpine 2.20 (LFD 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1711 Lines: 54 On Mon, 20 Jul 2015, Daniel Bristot de Oliveira wrote: > 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 > --- > 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 > Tested-by: John Kacur Works well, please apply -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/