]>
Commit | Line | Data |
---|---|---|
f68557eb GKH |
1 | From cf346d5bd4b9d61656df2f72565c9b354ef3ca0d Mon Sep 17 00:00:00 2001 |
2 | From: Arnaldo Carvalho de Melo <acme@redhat.com> | |
3 | Date: Tue, 25 Oct 2016 17:20:47 -0300 | |
4 | Subject: perf scripting: Avoid leaking the scripting_context variable | |
5 | ||
6 | From: Arnaldo Carvalho de Melo <acme@redhat.com> | |
7 | ||
8 | commit cf346d5bd4b9d61656df2f72565c9b354ef3ca0d upstream. | |
9 | ||
10 | Both register_perl_scripting() and register_python_scripting() allocate | |
11 | this variable, fix it by checking if it already was. | |
12 | ||
13 | Cc: Adrian Hunter <adrian.hunter@intel.com> | |
14 | Cc: David Ahern <dsahern@gmail.com> | |
15 | Cc: Frederic Weisbecker <fweisbec@gmail.com> | |
16 | Cc: Jiri Olsa <jolsa@kernel.org> | |
17 | Cc: Namhyung Kim <namhyung@kernel.org> | |
18 | Cc: Tom Zanussi <tzanussi@gmail.com> | |
19 | Cc: Wang Nan <wangnan0@huawei.com> | |
20 | Fixes: 7e4b21b84c43 ("perf/scripts: Add Python scripting engine") | |
21 | Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> | |
22 | Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> | |
23 | ||
24 | --- | |
25 | tools/perf/util/trace-event-scripting.c | 6 ++++-- | |
26 | 1 file changed, 4 insertions(+), 2 deletions(-) | |
27 | ||
28 | --- a/tools/perf/util/trace-event-scripting.c | |
29 | +++ b/tools/perf/util/trace-event-scripting.c | |
30 | @@ -95,7 +95,8 @@ static void register_python_scripting(st | |
31 | if (err) | |
32 | die("error registering py script extension"); | |
33 | ||
34 | - scripting_context = malloc(sizeof(struct scripting_context)); | |
35 | + if (scripting_context == NULL) | |
36 | + scripting_context = malloc(sizeof(*scripting_context)); | |
37 | } | |
38 | ||
39 | #ifdef NO_LIBPYTHON | |
40 | @@ -159,7 +160,8 @@ static void register_perl_scripting(stru | |
41 | if (err) | |
42 | die("error registering pl script extension"); | |
43 | ||
44 | - scripting_context = malloc(sizeof(struct scripting_context)); | |
45 | + if (scripting_context == NULL) | |
46 | + scripting_context = malloc(sizeof(*scripting_context)); | |
47 | } | |
48 | ||
49 | #ifdef NO_LIBPERL |