diff options
author | Quentin Monnet <quentin.monnet@netronome.com> | 2019-08-15 17:22:23 +0300 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-09-21 08:16:52 +0300 |
commit | 0d393f23f18ee1aa276ac93b681e1b1082fdb493 (patch) | |
tree | de34043f94c99428cc928c662e8e8d39150f010a | |
parent | c5bb033529f1847586aa73cd7e4991593cedf490 (diff) | |
download | linux-0d393f23f18ee1aa276ac93b681e1b1082fdb493.tar.xz |
tools: bpftool: close prog FD before exit on showing a single program
[ Upstream commit d34b044038bfb0e19caa8b019910efc465f41d5f ]
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>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
-rw-r--r-- | tools/bpf/bpftool/prog.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/tools/bpf/bpftool/prog.c b/tools/bpf/bpftool/prog.c index bbba0d61570f..4f9611af4642 100644 --- a/tools/bpf/bpftool/prog.c +++ b/tools/bpf/bpftool/prog.c @@ -381,7 +381,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) |