Re: [PATCHv2 bpf-next] selftests/bpf: Add missing bpf_iter_vma_offset__destroy call

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/6/22 1:31 AM, Jiri Olsa wrote:
Adding missing bpf_iter_vma_offset__destroy call and using in-skeletin
link pointer so we don't need extra bpf_link__destroy call.

Fixes: b3e1331eb925 ("selftests/bpf: Test parameterized task BPF iterators.")
Cc: Kui-Feng Lee <kuifeng@xxxxxx>
Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
---
  v2 changes:
  - use in-skeletin link pointer and destroy call [Martin]

  tools/testing/selftests/bpf/prog_tests/bpf_iter.c | 13 +++++++------
  1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_iter.c b/tools/testing/selftests/bpf/prog_tests/bpf_iter.c
index 3369c5ec3a17..d4437a2bba28 100644
--- a/tools/testing/selftests/bpf/prog_tests/bpf_iter.c
+++ b/tools/testing/selftests/bpf/prog_tests/bpf_iter.c
@@ -1498,7 +1498,6 @@ static noinline int trigger_func(int arg)
  static void test_task_vma_offset_common(struct bpf_iter_attach_opts *opts, bool one_proc)
  {
  	struct bpf_iter_vma_offset *skel;
-	struct bpf_link *link;
  	char buf[16] = {};
  	int iter_fd, len;
  	int pgsz, shift;
@@ -1513,11 +1512,13 @@ static void test_task_vma_offset_common(struct bpf_iter_attach_opts *opts, bool
  		;
  	skel->bss->page_shift = shift;
- link = bpf_program__attach_iter(skel->progs.get_vma_offset, opts);
-	if (!ASSERT_OK_PTR(link, "attach_iter"))
-		return;
+	skel->links.get_vma_offset = bpf_program__attach_iter(skel->progs.get_vma_offset, opts);
+	if (!ASSERT_OK_PTR(skel->links.get_vma_offset, "attach_iter")) {
+		skel->links.get_vma_offset = NULL;

Applied with this NULL assignment removed. bpf_link__destroy() can handle err ptr. Thanks.


+		goto exit;
+	}
- iter_fd = bpf_iter_create(bpf_link__fd(link));
+	iter_fd = bpf_iter_create(bpf_link__fd(skel->links.get_vma_offset));
  	if (!ASSERT_GT(iter_fd, 0, "create_iter"))
  		goto exit;
@@ -1535,7 +1536,7 @@ static void test_task_vma_offset_common(struct bpf_iter_attach_opts *opts, bool
  	close(iter_fd);
exit:
-	bpf_link__destroy(link);
+	bpf_iter_vma_offset__destroy(skel);
  }
static void test_task_vma_offset(void)




[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux