1 |
From b575e38244b9d816df1bd2ba5885c06f934235bd Mon Sep 17 00:00:00 2001 |
2 |
From: Sanskriti Sharma <sansharm@redhat.com> |
3 |
Date: Tue, 2 Oct 2018 10:29:11 -0400 |
4 |
Subject: [PATCH 019/145] perf tools: Cleanup trace-event-info 'tdata' leak |
5 |
|
6 |
[ Upstream commit faedbf3fd19f2511a39397f76359e4cc6ee93072 ] |
7 |
|
8 |
Free tracing_data structure in tracing_data_get() error paths. |
9 |
|
10 |
Fixes the following coverity complaint: |
11 |
|
12 |
Error: RESOURCE_LEAK (CWE-772): |
13 |
leaked_storage: Variable "tdata" going out of scope leaks the storage |
14 |
|
15 |
Signed-off-by: Sanskriti Sharma <sansharm@redhat.com> |
16 |
Reviewed-by: Jiri Olsa <jolsa@kernel.org> |
17 |
Cc: Joe Lawrence <joe.lawrence@redhat.com> |
18 |
Link: http://lkml.kernel.org/r/1538490554-8161-3-git-send-email-sansharm@redhat.com |
19 |
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> |
20 |
Signed-off-by: Sasha Levin <sashal@kernel.org> |
21 |
--- |
22 |
tools/perf/util/trace-event-info.c | 2 ++ |
23 |
1 file changed, 2 insertions(+) |
24 |
|
25 |
diff --git a/tools/perf/util/trace-event-info.c b/tools/perf/util/trace-event-info.c |
26 |
index 7b0ca7cbb7de..8ad8e755127b 100644 |
27 |
--- a/tools/perf/util/trace-event-info.c |
28 |
+++ b/tools/perf/util/trace-event-info.c |
29 |
@@ -531,12 +531,14 @@ struct tracing_data *tracing_data_get(struct list_head *pattrs, |
30 |
"/tmp/perf-XXXXXX"); |
31 |
if (!mkstemp(tdata->temp_file)) { |
32 |
pr_debug("Can't make temp file"); |
33 |
+ free(tdata); |
34 |
return NULL; |
35 |
} |
36 |
|
37 |
temp_fd = open(tdata->temp_file, O_RDWR); |
38 |
if (temp_fd < 0) { |
39 |
pr_debug("Can't read '%s'", tdata->temp_file); |
40 |
+ free(tdata); |
41 |
return NULL; |
42 |
} |
43 |
|
44 |
-- |
45 |
2.19.1 |
46 |
|