linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] selftests/bpf: Fix return value check in attach_bpf()
@ 2021-05-28  9:07 Yu Kuai
  2021-05-28 20:46 ` Daniel Borkmann
  2021-05-28 21:16 ` John Fastabend
  0 siblings, 2 replies; 6+ messages in thread
From: Yu Kuai @ 2021-05-28  9:07 UTC (permalink / raw)
  To: shuah, ast, daniel, andrii
  Cc: linux-kselftest, netdev, bpf, linux-kernel, yukuai3, yi.zhang

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

Reported-by: Hulk Robot <hulkci@huawei.com>
Signed-off-by: Yu Kuai <yukuai3@huawei.com>
---
 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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2021-05-30  1:17 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-28  9:07 [PATCH] selftests/bpf: Fix return value check in attach_bpf() Yu Kuai
2021-05-28 20:46 ` Daniel Borkmann
2021-05-29  1:25   ` yukuai (C)
2021-05-30  1:17     ` Andrii Nakryiko
2021-05-28 21:16 ` John Fastabend
2021-05-28 21:19   ` John Fastabend

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).