Re: [PATCH 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/2/22 8:11 AM, Jiri Olsa wrote:
Adding missing bpf_iter_vma_offset__destroy call to
test_task_vma_offset_common function and related goto jumps.

Fixes: b3e1331eb925 ("selftests/bpf: Test parameterized task BPF iterators.")
Cc: Kui-Feng Lee <kuifeng@xxxxxx>
Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx>
---
  tools/testing/selftests/bpf/prog_tests/bpf_iter.c | 8 +++++---
  1 file changed, 5 insertions(+), 3 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..462fe92e0736 100644
--- a/tools/testing/selftests/bpf/prog_tests/bpf_iter.c
+++ b/tools/testing/selftests/bpf/prog_tests/bpf_iter.c
@@ -1515,11 +1515,11 @@ static void test_task_vma_offset_common(struct bpf_iter_attach_opts *opts, bool
link = bpf_program__attach_iter(skel->progs.get_vma_offset, opts);

Thanks for the fix.

A nit.  Instead of adding a new goto label.  How about doing

	skel->links.get_vma_offset = bpf_program_attach_iter(...)

and bpf_iter_vma_offset__destroy(skel) will take care of the link destroy. The earlier test_task_vma_common() is doing that also.

Kui-Feng, please also take a look.

  	if (!ASSERT_OK_PTR(link, "attach_iter"))
-		return;
+		goto exit_skel;
iter_fd = bpf_iter_create(bpf_link__fd(link));
  	if (!ASSERT_GT(iter_fd, 0, "create_iter"))
-		goto exit;
+		goto exit_link;
while ((len = read(iter_fd, buf, sizeof(buf))) > 0)
  		;
@@ -1534,8 +1534,10 @@ static void test_task_vma_offset_common(struct bpf_iter_attach_opts *opts, bool
close(iter_fd); -exit:
+exit_link:
  	bpf_link__destroy(link);
+exit_skel:
+	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