Skip to content

Commit 358b1c0

Browse files
aspskanakryiko
authored andcommitted
libbpf: Use proper errno value in linker
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: faf6ed3 ("libbpf: Add BPF static linker APIs") Signed-off-by: Anton Protopopov <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 38d976c commit 358b1c0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

tools/lib/bpf/linker.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1376,7 +1376,7 @@ static int linker_append_sec_data(struct bpf_linker *linker, struct src_obj *obj
13761376
} else {
13771377
if (!secs_match(dst_sec, src_sec)) {
13781378
pr_warn("ELF sections %s are incompatible\n", src_sec->sec_name);
1379-
return -1;
1379+
return -EINVAL;
13801380
}
13811381

13821382
/* "license" and "version" sections are deduped */
@@ -2223,7 +2223,7 @@ static int linker_append_elf_relos(struct bpf_linker *linker, struct src_obj *ob
22232223
}
22242224
} else if (!secs_match(dst_sec, src_sec)) {
22252225
pr_warn("sections %s are not compatible\n", src_sec->sec_name);
2226-
return -1;
2226+
return -EINVAL;
22272227
}
22282228

22292229
/* shdr->sh_link points to SYMTAB */

0 commit comments

Comments
 (0)