Thread (6 messages) 6 messages, 4 authors, 2021-05-30

[PATCH] selftests/bpf: Fix return value check in attach_bpf()

From: Yu Kuai <hidden>
Date: 2021-05-28 08:58:46
Also in: bpf, linux-kselftest, netdev
Subsystem: bpf [general] (safe dynamic programs and tools), bpf [selftests] (test runners & infrastructure), kernel selftest framework, the rest · Maintainers: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko, Eduard Zingerman, Kumar Kartikeya Dwivedi, Shuah Khan, Linus Torvalds

use libbpf_get_error() to check the return value of
bpf_program__attach().

Reported-by: Hulk Robot <redacted>
Signed-off-by: Yu Kuai <redacted>
---
 tools/testing/selftests/bpf/benchs/bench_rename.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/bpf/benchs/bench_rename.c b/tools/testing/selftests/bpf/benchs/bench_rename.c
index c7ec114eca56..b7d4a1d74fca 100644
--- a/tools/testing/selftests/bpf/benchs/bench_rename.c
+++ b/tools/testing/selftests/bpf/benchs/bench_rename.c
@@ -65,7 +65,7 @@ static void attach_bpf(struct bpf_program *prog)
 	struct bpf_link *link;
 
 	link = bpf_program__attach(prog);
-	if (!link) {
+	if (libbpf_get_error(link)) {
 		fprintf(stderr, "failed to attach program!\n");
 		exit(1);
 	}
-- 
2.25.4
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help