Skip to content

Commit 5436a54

Browse files
Pu Lehuianakryiko
authored andcommitted
libbpf: Fix return zero when elf_begin failed
The error number of elf_begin is omitted when encapsulating the btf_find_elf_sections function. Fixes: c86f180 ("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
1 parent 4a04cb3 commit 5436a54

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

tools/lib/bpf/btf.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,6 +1186,7 @@ static struct btf *btf_parse_elf(const char *path, struct btf *base_btf,
11861186

11871187
elf = elf_begin(fd, ELF_C_READ, NULL);
11881188
if (!elf) {
1189+
err = -LIBBPF_ERRNO__FORMAT;
11891190
pr_warn("failed to open %s as ELF file\n", path);
11901191
goto done;
11911192
}

0 commit comments

Comments
 (0)