Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: 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

authored by

Pu Lehui and committed by
Andrii Nakryiko
5436a543 4a04cb32

+1
+1
tools/lib/bpf/btf.c
··· 1186 1186 1187 1187 elf = elf_begin(fd, ELF_C_READ, NULL); 1188 1188 if (!elf) { 1189 + err = -LIBBPF_ERRNO__FORMAT; 1189 1190 pr_warn("failed to open %s as ELF file\n", path); 1190 1191 goto done; 1191 1192 }