netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf] tools: bpftool: close prog FD before exit on showing a single program
@ 2019-08-15 14:22 Quentin Monnet
  2019-08-15 17:09 ` Andrii Nakryiko
  2019-08-16  5:11 ` Alexei Starovoitov
  0 siblings, 2 replies; 7+ messages in thread
From: Quentin Monnet @ 2019-08-15 14:22 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann
  Cc: bpf, netdev, oss-drivers, Quentin Monnet

When showing metadata about a single program by invoking
"bpftool prog show PROG", the file descriptor referring to the program
is not closed before returning from the function. Let's close it.

Fixes: 71bb428fe2c1 ("tools: bpf: add bpftool")
Signed-off-by: Quentin Monnet <quentin.monnet@netronome.com>
Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
---
 tools/bpf/bpftool/prog.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c
index 66f04a4846a5..43fdbbfe41bb 100644
--- a/tools/bpf/bpftool/prog.c
+++ b/tools/bpf/bpftool/prog.c
@@ -363,7 +363,9 @@ static int do_show(int argc, char **argv)
 		if (fd < 0)
 			return -1;
 
-		return show_prog(fd);
+		err = show_prog(fd);
+		close(fd);
+		return err;
 	}
 
 	if (argc)
-- 
2.17.1


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

end of thread, other threads:[~2019-08-16  5:11 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-15 14:22 [PATCH bpf] tools: bpftool: close prog FD before exit on showing a single program Quentin Monnet
2019-08-15 17:09 ` Andrii Nakryiko
2019-08-15 17:30   ` Jakub Kicinski
2019-08-15 18:05     ` Andrii Nakryiko
2019-08-15 18:09       ` Jakub Kicinski
2019-08-15 20:16         ` Andrii Nakryiko
2019-08-16  5:11 ` Alexei Starovoitov

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).