summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorPu Lehui <pulehui@huawei.com>2025-01-15 10:02:39 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-02-08 09:57:34 +0100
commitbeadb92ea609c9694e88e50e04816cb033630655 (patch)
tree882a05058cb54ca1eac18c1b0ffd3748d3ced458 /tools
parent20c84906e2da6561b3e7981e0a40f42ffd0b0777 (diff)
downloadlinux-beadb92ea609c9694e88e50e04816cb033630655.tar.gz
linux-beadb92ea609c9694e88e50e04816cb033630655.tar.bz2
linux-beadb92ea609c9694e88e50e04816cb033630655.zip
libbpf: Fix return zero when elf_begin failed
[ Upstream commit 5436a54332c19df0acbef2b87cbf9f7cba56f2dd ] The error number of elf_begin is omitted when encapsulating the btf_find_elf_sections function. Fixes: c86f180ffc99 ("libbpf: Make btf_parse_elf process .BTF.base transparently") Signed-off-by: Pu Lehui <pulehui@huawei.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20250115100241.4171581-2-pulehui@huaweicloud.com Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/lib/bpf/btf.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/tools/lib/bpf/btf.c b/tools/lib/bpf/btf.c
index 3c131039c523..27e7bfae953b 100644
--- a/tools/lib/bpf/btf.c
+++ b/tools/lib/bpf/btf.c
@@ -1185,6 +1185,7 @@ static struct btf *btf_parse_elf(const char *path, struct btf *base_btf,
elf = elf_begin(fd, ELF_C_READ, NULL);
if (!elf) {
+ err = -LIBBPF_ERRNO__FORMAT;
pr_warn("failed to open %s as ELF file\n", path);
goto done;
}