Skip to content

Commit f0ba7b6

Browse files
alexgartrellgregkh
authored andcommitted
libbpf: Fix unintentional success return code in bpf_object__load
[ Upstream commit ef05afa ] There are code paths where EINVAL is returned directly without setting errno. In that case, errno could be 0, which would mask the failure. For example, if a careless programmer set log_level to 10000 out of laziness, they would have to spend a long time trying to figure out why. Fixes: 4f33ddb ("libbpf: Propagate EPERM to caller on program load") Signed-off-by: Alex Gartrell <alexgartrell@gmail.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/20200826075549.1858580-1-alexgartrell@gmail.com Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 7942b61 commit f0ba7b6

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

tools/lib/bpf/libbpf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5425,7 +5425,7 @@ load_program(struct bpf_program *prog, struct bpf_insn *insns, int insns_cnt,
54255425
free(log_buf);
54265426
goto retry_load;
54275427
}
5428-
ret = -errno;
5428+
ret = errno ? -errno : -LIBBPF_ERRNO__LOAD;
54295429
cp = libbpf_strerror_r(errno, errmsg, sizeof(errmsg));
54305430
pr_warn("load bpf program failed: %s\n", cp);
54315431
pr_perm_msg(ret);

0 commit comments

Comments
 (0)