libbpf: Close fd in bpf_object__reuse_map
PATCH 1/1 libbpf: Close fd in bpf_object__reuse_map
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 <[email protected]>
--- tools/lib/bpf/libbpf.c | 1 + 1 file changed, 1 insertion(+)
tools/lib/bpf/libbpf.c +1 -0
@@ -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);
Signature · 1 line
2.25.1
Daniel Borkmann
maintainer[ Cc +Toke ]
Quoted 14 lines · Hengqi Chen
pin_fdis dup-ed and assigned inbpf_map__reuse_fd. Close it after reuse successfully.Fixes [email protected] ("libbpf: Add auto-pinning of maps when loading BPF objects")Signed-off-by Hengqi Chen <[email protected]>--- tools/lib/bpf/libbpf.c | 1 + 1 file changed, 1 insertion(+)tools/lib/bpf/libbpf.c +0
-0
tools/lib/bpf/libbpf.c bpf_object__reuse_map(struct bpf_map *map) · line 4807
Quoted 4 lines
tools/lib/bpf/libbpf.c +1
-0@@ -4804,6 +4804,7 @@ bpf_object__reuse_map(struct bpf_map *map)close (pin_fd);return err; } +close (pin_fd);
Lgtm, but in that case, pls just do ...
err = bpf_map__reuse_fd(map, pin_fd);
close(pin_fd);
if (err)
return err;
[...]... given we close it in both branches.
Quoted 4 lines
tools/lib/bpf/libbpf.c +0
-0map->pinned = true;pr_debug ("reused pinned map at '%s'\n" , map->pin_path);