/[packages]/cauldron/kernel/current/PATCHES/patches/0018-perf-tools-Free-temporary-sys-string-in-read_event_f.patch
ViewVC logotype

Contents of /cauldron/kernel/current/PATCHES/patches/0018-perf-tools-Free-temporary-sys-string-in-read_event_f.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1329221 - (show annotations) (download)
Fri Nov 9 22:05:45 2018 UTC (5 years, 10 months ago) by tmb
File size: 1773 byte(s)
add fixes from sashas autosel queue
1 From cff24485cec6813e1351c3ca752adc3a7896dc9c Mon Sep 17 00:00:00 2001
2 From: Sanskriti Sharma <sansharm@redhat.com>
3 Date: Tue, 2 Oct 2018 10:29:14 -0400
4 Subject: [PATCH 018/145] perf tools: Free temporary 'sys' string in
5 read_event_files()
6
7 [ Upstream commit 1e44224fb0528b4c0cc176bde2bb31e9127eb14b ]
8
9 For each system in a given pevent, read_event_files() reads in a
10 temporary 'sys' string. Be sure to free this string before moving onto
11 to the next system and/or leaving read_event_files().
12
13 Fixes the following coverity complaints:
14
15 Error: RESOURCE_LEAK (CWE-772):
16
17 tools/perf/util/trace-event-read.c:343: overwrite_var: Overwriting
18 "sys" in "sys = read_string()" leaks the storage that "sys" points to.
19
20 tools/perf/util/trace-event-read.c:353: leaked_storage: Variable "sys"
21 going out of scope leaks the storage it points to.
22
23 Signed-off-by: Sanskriti Sharma <sansharm@redhat.com>
24 Reviewed-by: Jiri Olsa <jolsa@kernel.org>
25 Cc: Joe Lawrence <joe.lawrence@redhat.com>
26 Link: http://lkml.kernel.org/r/1538490554-8161-6-git-send-email-sansharm@redhat.com
27 Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
28 Signed-off-by: Sasha Levin <sashal@kernel.org>
29 ---
30 tools/perf/util/trace-event-read.c | 5 ++++-
31 1 file changed, 4 insertions(+), 1 deletion(-)
32
33 diff --git a/tools/perf/util/trace-event-read.c b/tools/perf/util/trace-event-read.c
34 index 3dfc1db6b25b..5eb1b2469bba 100644
35 --- a/tools/perf/util/trace-event-read.c
36 +++ b/tools/perf/util/trace-event-read.c
37 @@ -349,9 +349,12 @@ static int read_event_files(struct tep_handle *pevent)
38 for (x=0; x < count; x++) {
39 size = read8(pevent);
40 ret = read_event_file(pevent, sys, size);
41 - if (ret)
42 + if (ret) {
43 + free(sys);
44 return ret;
45 + }
46 }
47 + free(sys);
48 }
49 return 0;
50 }
51 --
52 2.19.1
53

  ViewVC Help
Powered by ViewVC 1.1.30