Skip to content

Commit

Permalink
tools: bpftool: close prog FD before exit on showing a single program
Browse files Browse the repository at this point in the history
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: 71bb428 ("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>
  • Loading branch information
Quentin Monnet authored and Alexei Starovoitov committed Aug 16, 2019
1 parent 27df5c7 commit d34b044
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion tools/bpf/bpftool/prog.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit d34b044

Please sign in to comment.