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


Groups > linux.kernel > #1510656

[PATCH 13/15] perf scripting: Avoid leaking the scripting_context variable

From Arnaldo Carvalho de Melo <acme@kernel.org>
Newsgroups linux.kernel
Subject [PATCH 13/15] perf scripting: Avoid leaking the scripting_context variable
Date 2016-10-27 22:50 +0200
Message-ID <swZMC-6Nm-75@gated-at.bofh.it> (permalink)
References <swZMB-6Nm-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


From: Arnaldo Carvalho de Melo <acme@redhat.com>

Both register_perl_scripting() and register_python_scripting() allocate
this variable, fix it by checking if it already was.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Tom Zanussi <tzanussi@gmail.com>
Cc: Wang Nan <wangnan0@huawei.com>
Fixes: 7e4b21b84c43 ("perf/scripts: Add Python scripting engine")
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
---
 tools/perf/util/trace-event-scripting.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/trace-event-scripting.c b/tools/perf/util/trace-event-scripting.c
index 9df61059a85d..a2fd6e79d5a5 100644
--- a/tools/perf/util/trace-event-scripting.c
+++ b/tools/perf/util/trace-event-scripting.c
@@ -95,7 +95,8 @@ static void register_python_scripting(struct scripting_ops *scripting_ops)
 	if (err)
 		die("error registering py script extension");
 
-	scripting_context = malloc(sizeof(struct scripting_context));
+	if (scripting_context == NULL)
+		scripting_context = malloc(sizeof(*scripting_context));
 }
 
 #ifdef NO_LIBPYTHON
@@ -159,7 +160,8 @@ static void register_perl_scripting(struct scripting_ops *scripting_ops)
 	if (err)
 		die("error registering pl script extension");
 
-	scripting_context = malloc(sizeof(struct scripting_context));
+	if (scripting_context == NULL)
+		scripting_context = malloc(sizeof(*scripting_context));
 }
 
 #ifdef NO_LIBPERL
-- 
2.7.4

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


Thread

[GIT PULL 00/15] perf/core improvements and fixes Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-10-27 22:50 +0200
  [PATCH 02/15] perf bench futex: Sanitize numeric parameters Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-10-27 22:50 +0200
  [PATCH 04/15] tools lib subcmd: Suppport cascading options Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-10-27 22:50 +0200
  [PATCH 09/15] perf list: Support matching by topic Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-10-27 22:50 +0200
  [PATCH 08/15] perf tools: Introduce timestamp_in_usec() Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-10-27 22:50 +0200
    Re: [PATCH 08/15] perf tools: Introduce timestamp_in_usec() Joonwoo Park <joonwoop@codeaurora.org> - 2016-10-28 01:20 +0200
      Re: [PATCH 08/15] perf tools: Introduce timestamp_in_usec() Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-10-28 15:00 +0200
        Re: [PATCH 08/15] perf tools: Introduce timestamp_in_usec() Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-10-28 15:40 +0200
          [GIT PULL] Re: [PATCH 08/15] perf tools: Introduce  timestamp_in_usec() Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-10-28 16:50 +0200
            Re: [GIT PULL] Re: [PATCH 08/15] perf tools: Introduce  timestamp_in_usec() Ingo Molnar <mingo@kernel.org> - 2016-10-28 19:50 +0200
              Re: [GIT PULL] Re: [PATCH 08/15] perf tools: Introduce  timestamp_in_usec() Joonwoo Park <joonwoop@codeaurora.org> - 2016-10-28 19:50 +0200
  [PATCH 13/15] perf scripting: Avoid leaking the scripting_context variable Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-10-27 22:50 +0200
  [PATCH 14/15] perf scripting: Don't die if scripting can't be setup, disable it Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-10-27 22:50 +0200
  [PATCH 07/15] perf sched map: Always show task comm with -v Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-10-27 22:50 +0200
  [PATCH 10/15] perf bench mem: Ignore export.h related changes to mem{cpy,set}.S Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-10-27 22:50 +0200
  [PATCH 11/15] tools: Update asm-generic/mman-common.h copy from the kernel Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-10-27 22:50 +0200
  [PATCH 01/15] perf bench futex: Avoid worker cacheline bouncing Arnaldo Carvalho de Melo <acme@kernel.org> - 2016-10-27 22:50 +0200

csiph-web