Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1348561

[PATCH 06/11] tools lib traceevent: Set int_array fields to NULL if freeing from error

From Arnaldo Carvalho de Melo <acme@kernel.org>
Newsgroups linux.kernel
Subject [PATCH 06/11] tools lib traceevent: Set int_array fields to NULL if freeing from error
Date 2016-03-02 23:20 +0100
Message-ID <r8nhF-5Zk-45@gated-at.bofh.it> (permalink)
References <r8nhD-5Zk-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: "Steven Rostedt (Red Hat)" <rostedt@goodmis.org>

Had a bug where on error of parsing __print_array() where the fields are
freed after they were allocated, but since they were not set to NULL,
the freeing of the arg also tried to free the already freed fields
causing a double free.

Fix process_hex() while at it.

Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Link: http://lkml.kernel.org/r/20160209204237.188327674@goodmis.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/lib/traceevent/event-parse.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/lib/traceevent/event-parse.c b/tools/lib/traceevent/event-parse.c
index ce59f4891fa2..fb790aa757eb 100644
--- a/tools/lib/traceevent/event-parse.c
+++ b/tools/lib/traceevent/event-parse.c
@@ -2635,6 +2635,7 @@ process_hex(struct event_format *event, struct print_arg *arg, char **tok)
 
 free_field:
 	free_arg(arg->hex.field);
+	arg->hex.field = NULL;
 out:
 	*tok = NULL;
 	return EVENT_ERROR;
@@ -2659,8 +2660,10 @@ process_int_array(struct event_format *event, struct print_arg *arg, char **tok)
 
 free_size:
 	free_arg(arg->int_array.count);
+	arg->int_array.count = NULL;
 free_field:
 	free_arg(arg->int_array.field);
+	arg->int_array.field = NULL;
 out:
 	*tok = NULL;
 	return EVENT_ERROR;
-- 
2.5.0

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[GIT PULL 00/11] perf/core improvements and fixes Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-03-02 23:20 +0100
  [PATCH 04/11] perf script: Fix double free on command_line Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-03-02 23:20 +0100
  [PATCH 08/11] perf test: Fix hists related entries Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-03-02 23:20 +0100
  [PATCH 09/11] perf tests: Initialize sa.sa_flags Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-03-02 23:20 +0100
  [PATCH 06/11] tools lib traceevent: Set int_array fields to NULL if freeing from error Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-03-02 23:20 +0100
  [PATCH 01/11] perf stat: Implement CSV metrics output Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-03-02 23:20 +0100
  [PATCH 03/11] tools build: Use .s extension for preprocessed assembler code Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-03-02 23:30 +0100

csiph-web