pin_fd is dup-ed and assigned in bpf_map__reuse_fd. Close it after reuse successfully. Fixes: 57a00f41644f ("libbpf: Add auto-pinning of maps when loading BPF objects") Signed-off-by: Hengqi Chen <hengqi.chen@xxxxxxxxx> --- tools/lib/bpf/libbpf.c | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index 43161fdd44bb..10ad500f1d6e 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c @@ -4804,6 +4804,7 @@ bpf_object__reuse_map(struct bpf_map *map) close(pin_fd); return err; } + close(pin_fd); map->pinned = true; pr_debug("reused pinned map at '%s'\n", map->pin_path); -- 2.25.1