linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] perf cgroup: Avoid needless closing of unopened fd
@ 2020-04-17 13:23 Tommi Rantala
  2020-04-17 13:23 ` [PATCH 2/4] perf tools: Move zstd_fini() to session deletion Tommi Rantala
                   ` (4 more replies)
  0 siblings, 5 replies; 13+ messages in thread
From: Tommi Rantala @ 2020-04-17 13:23 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo, Ingo Molnar
  Cc: Tommi Rantala, Peter Zijlstra, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, Namhyung Kim, linux-kernel

Do not bother with close() if fd is not valid, just to silence valgrind:

    $ valgrind ./perf script
    ==59169== Memcheck, a memory error detector
    ==59169== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
    ==59169== Using Valgrind-3.14.0 and LibVEX; rerun with -h for copyright info
    ==59169== Command: ./perf script
    ==59169==
    ==59169== Warning: invalid file descriptor -1 in syscall close()
    ==59169== Warning: invalid file descriptor -1 in syscall close()
    ==59169== Warning: invalid file descriptor -1 in syscall close()
    ==59169== Warning: invalid file descriptor -1 in syscall close()
    ==59169== Warning: invalid file descriptor -1 in syscall close()
    ==59169== Warning: invalid file descriptor -1 in syscall close()
    ==59169== Warning: invalid file descriptor -1 in syscall close()
    ==59169== Warning: invalid file descriptor -1 in syscall close()

Signed-off-by: Tommi Rantala <tommi.t.rantala@nokia.com>
---
 tools/perf/util/cgroup.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/perf/util/cgroup.c b/tools/perf/util/cgroup.c
index b73fb7823048..050dea9f1e88 100644
--- a/tools/perf/util/cgroup.c
+++ b/tools/perf/util/cgroup.c
@@ -107,7 +107,8 @@ static int add_cgroup(struct evlist *evlist, const char *str)
 
 static void cgroup__delete(struct cgroup *cgroup)
 {
-	close(cgroup->fd);
+	if (cgroup->fd >= 0)
+		close(cgroup->fd);
 	zfree(&cgroup->name);
 	free(cgroup);
 }
-- 
2.25.2


^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2020-05-08 13:07 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-04-17 13:23 [PATCH 1/4] perf cgroup: Avoid needless closing of unopened fd Tommi Rantala
2020-04-17 13:23 ` [PATCH 2/4] perf tools: Move zstd_fini() to session deletion Tommi Rantala
2020-04-20  8:54   ` Jiri Olsa
2020-04-23  5:52     ` Rantala, Tommi T. (Nokia - FI/Espoo)
2020-04-17 13:23 ` [PATCH 3/4] perf tools: Fix segfaults due to missing zstd decompressor initialization Tommi Rantala
2020-04-20  9:05   ` Jiri Olsa
2020-04-17 13:23 ` [PATCH 4/4] perf bench: Fix div-by-zero if runtime is zero Tommi Rantala
2020-04-20  9:05   ` Jiri Olsa
2020-04-20 12:05     ` Arnaldo Carvalho de Melo
2020-05-08 13:05   ` [tip: perf/core] " tip-bot2 for Tommi Rantala
2020-04-20  8:48 ` [PATCH 1/4] perf cgroup: Avoid needless closing of unopened fd Jiri Olsa
2020-04-20 12:05   ` Arnaldo Carvalho de Melo
2020-05-08 13:05 ` [tip: perf/core] " tip-bot2 for Tommi Rantala

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).