]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commit
libbpf: Fix error handling in bpf_map__reuse_fd()
authorToke Høiland-Jørgensen <toke@redhat.com>
Sat, 2 Nov 2019 11:09:37 +0000 (12:09 +0100)
committerSeth Forshee <seth.forshee@canonical.com>
Mon, 6 Jan 2020 14:16:09 +0000 (08:16 -0600)
commit4e08326e0fb3354e3cf5be41ffa2290e5b7fe722
treea5d44aad8750bbe3269e9a0f1d78d93bdb3bdfc3
parenta664be32b2423ff8d9fa1aca48ef42475fe87abf
libbpf: Fix error handling in bpf_map__reuse_fd()

BugLink: https://bugs.launchpad.net/bugs/1858428
[ Upstream commit d1b4574a4b86565325ef2e545eda8dfc9aa07c60 ]

bpf_map__reuse_fd() was calling close() in the error path before returning
an error value based on errno. However, close can change errno, so that can
lead to potentially misleading error messages. Instead, explicitly store
errno in the err variable before each goto.

Signed-off-by: Toke Høiland-Jørgensen <toke@redhat.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Andrii Nakryiko <andriin@fb.com>
Link: https://lore.kernel.org/bpf/157269297769.394725.12634985106772698611.stgit@toke.dk
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Seth Forshee <seth.forshee@canonical.com>
tools/lib/bpf/libbpf.c