]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
libbpf: Fix return zero when elf_begin failed
authorPu Lehui <pulehui@huawei.com>
Wed, 15 Jan 2025 10:02:39 +0000 (10:02 +0000)
committerAndrii Nakryiko <andrii@kernel.org>
Thu, 16 Jan 2025 23:34:18 +0000 (15:34 -0800)
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
tools/lib/bpf/btf.c

index a4ae2df68b9140091364ffa3b5bb8032d6faa058..48c66f3a9200210c23a27a94cc89f279bd75e67e 100644 (file)
@@ -1186,6 +1186,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;
        }