summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorAnton Protopopov <a.s.protopopov@gmail.com>2025-04-30 12:08:20 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2025-06-27 11:05:12 +0100
commitc6c7e7ab962b1f9f35b7efb159533409a3272008 (patch)
tree01e9c0616f863a904e9142979934e19c019387f9 /tools
parenta6412e93cf4adb8447c11f6ab53c03e12adf1d9a (diff)
downloadlinux-c6c7e7ab962b1f9f35b7efb159533409a3272008.tar.gz
linux-c6c7e7ab962b1f9f35b7efb159533409a3272008.tar.bz2
linux-c6c7e7ab962b1f9f35b7efb159533409a3272008.zip
libbpf: Use proper errno value in linker
[ Upstream commit 358b1c0f56ebb6996fcec7dcdcf6bae5dcbc8b6c ] Return values of the linker_append_sec_data() and the linker_append_elf_relos() functions are propagated all the way up to users of libbpf API. In some error cases these functions return -1 which will be seen as -EPERM from user's point of view. Instead, return a more reasonable -EINVAL. Fixes: faf6ed321cf6 ("libbpf: Add BPF static linker APIs") Signed-off-by: Anton Protopopov <a.s.protopopov@gmail.com> Signed-off-by: Andrii Nakryiko <andrii@kernel.org> Link: https://lore.kernel.org/bpf/20250430120820.2262053-1-a.s.protopopov@gmail.com Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/lib/bpf/linker.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/lib/bpf/linker.c b/tools/lib/bpf/linker.c
index fc91814a35e8..3e06af5b5352 100644
--- a/tools/lib/bpf/linker.c
+++ b/tools/lib/bpf/linker.c
@@ -1181,7 +1181,7 @@ static int linker_append_sec_data(struct bpf_linker *linker, struct src_obj *obj
} else {
if (!secs_match(dst_sec, src_sec)) {
pr_warn("ELF sections %s are incompatible\n", src_sec->sec_name);
- return -1;
+ return -EINVAL;
}
/* "license" and "version" sections are deduped */
@@ -2027,7 +2027,7 @@ static int linker_append_elf_relos(struct bpf_linker *linker, struct src_obj *ob
}
} else if (!secs_match(dst_sec, src_sec)) {
pr_warn("sections %s are not compatible\n", src_sec->sec_name);
- return -1;
+ return -EINVAL;
}
/* add_dst_sec() above could have invalidated linker->secs */