[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20211101124310.3947887-1-yangyingliang@huawei.com>
Date: Mon, 1 Nov 2021 20:43:10 +0800
From: Yang Yingliang <yangyingliang@...wei.com>
To: <linux-kernel@...r.kernel.org>, <bpf@...r.kernel.org>
CC: <linux-kselftest@...r.kernel.org>, <shuah@...nel.org>,
<ast@...nel.org>, <yhs@...com>
Subject: [PATCH -next v2] bpf/benchs: Fix return value check of bpf_program__attach()
If bpf_program__attach() fails, it never returns NULL,
we should use libbpf_get_error() to check the return value.
Reported-by: Hulk Robot <hulkci@...wei.com>
Signed-off-by: Yang Yingliang <yangyingliang@...wei.com>
Acked-by: Yonghong Song <yhs@...com>
---
v2:
don't use 'int err'
---
.../selftests/bpf/benchs/bench_bloom_filter_map.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/tools/testing/selftests/bpf/benchs/bench_bloom_filter_map.c b/tools/testing/selftests/bpf/benchs/bench_bloom_filter_map.c
index 6eeeed2913e6..4afaa4adb327 100644
--- a/tools/testing/selftests/bpf/benchs/bench_bloom_filter_map.c
+++ b/tools/testing/selftests/bpf/benchs/bench_bloom_filter_map.c
@@ -304,7 +304,7 @@ static void bloom_lookup_setup(void)
populate_maps();
link = bpf_program__attach(ctx.skel->progs.bloom_lookup);
- if (!link) {
+ if (libbpf_get_error(link)) {
fprintf(stderr, "failed to attach program!\n");
exit(1);
}
@@ -321,7 +321,7 @@ static void bloom_update_setup(void)
populate_maps();
link = bpf_program__attach(ctx.skel->progs.bloom_update);
- if (!link) {
+ if (libbpf_get_error(link)) {
fprintf(stderr, "failed to attach program!\n");
exit(1);
}
@@ -340,7 +340,7 @@ static void false_positive_setup(void)
populate_maps();
link = bpf_program__attach(ctx.skel->progs.bloom_hashmap_lookup);
- if (!link) {
+ if (libbpf_get_error(link)) {
fprintf(stderr, "failed to attach program!\n");
exit(1);
}
@@ -358,7 +358,7 @@ static void hashmap_with_bloom_setup(void)
populate_maps();
link = bpf_program__attach(ctx.skel->progs.bloom_hashmap_lookup);
- if (!link) {
+ if (libbpf_get_error(link)) {
fprintf(stderr, "failed to attach program!\n");
exit(1);
}
@@ -375,7 +375,7 @@ static void hashmap_no_bloom_setup(void)
populate_maps();
link = bpf_program__attach(ctx.skel->progs.bloom_hashmap_lookup);
- if (!link) {
+ if (libbpf_get_error(link)) {
fprintf(stderr, "failed to attach program!\n");
exit(1);
}
--
2.25.1
Powered by blists - more mailing lists