From: Hengqi Chen <hengqi.chen@gmail.com>
To: bpf@vger.kernel.org
Cc: hengqi.chen@gmail.com
Subject: [PATCH bpf-next] libbpf: Close fd in bpf_object__reuse_map
Date: Thu, 17 Mar 2022 10:03:01 +0800 [thread overview]
Message-ID: <20220317020301.2680432-1-hengqi.chen@gmail.com> (raw)
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@gmail.com>
---
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
next reply other threads:[~2022-03-17 2:03 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-17 2:03 Hengqi Chen [this message]
2022-03-18 14:55 ` [PATCH bpf-next] libbpf: Close fd in bpf_object__reuse_map Daniel Borkmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220317020301.2680432-1-hengqi.chen@gmail.com \
--to=hengqi.chen@gmail.com \
--cc=bpf@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox