Commit ef05afa6 authored by Alex Gartrell's avatar Alex Gartrell Committed by Alexei Starovoitov
Browse files

libbpf: Fix unintentional success return code in bpf_object__load



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: 4f33ddb4 ("libbpf: Propagate EPERM to caller on program load")
Signed-off-by: default avatarAlex Gartrell <alexgartrell@gmail.com>
Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20200826075549.1858580-1-alexgartrell@gmail.com
parent 1fc0e18b
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -6067,7 +6067,7 @@ retry_load:
		free(log_buf);
		goto retry_load;
	}
	ret = -errno;
	ret = errno ? -errno : -LIBBPF_ERRNO__LOAD;
	cp = libbpf_strerror_r(errno, errmsg, sizeof(errmsg));
	pr_warn("load bpf program failed: %s\n", cp);
	pr_perm_msg(ret);