aboutsummaryrefslogtreecommitdiff
path: root/tools/perf/lib
diff options
context:
space:
mode:
authorAndi Kleen <[email protected]>2019-10-20 10:51:55 -0700
committerArnaldo Carvalho de Melo <[email protected]>2019-11-06 15:43:05 -0300
commit2ccfb8bc2143ca347609d1d4434176d73a78d805 (patch)
treead11f89aa5f7cf704c4a2dca43d9dd0504eaaa31 /tools/perf/lib
parent796c01a4bfb4b35ec6d1bd1cd5d520515d078b51 (diff)
perf evsel: Avoid close(-1)
In some weak fallback cases close can be called a lot with -1. Check for this case and avoid calling close then. This is mainly to shut up valgrind which complains about this case. Signed-off-by: Andi Kleen <[email protected]> Acked-by: Jiri Olsa <[email protected]> Cc: Kan Liang <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephane Eranian <[email protected]> Link: http://lore.kernel.org/lkml/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
Diffstat (limited to 'tools/perf/lib')
-rw-r--r--tools/perf/lib/evsel.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/tools/perf/lib/evsel.c b/tools/perf/lib/evsel.c
index a8cb582e2721..5a89857b0381 100644
--- a/tools/perf/lib/evsel.c
+++ b/tools/perf/lib/evsel.c
@@ -120,7 +120,8 @@ void perf_evsel__close_fd(struct perf_evsel *evsel)
for (cpu = 0; cpu < xyarray__max_x(evsel->fd); cpu++)
for (thread = 0; thread < xyarray__max_y(evsel->fd); ++thread) {
- close(FD(evsel, cpu, thread));
+ if (FD(evsel, cpu, thread) >= 0)
+ close(FD(evsel, cpu, thread));
FD(evsel, cpu, thread) = -1;
}
}