public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: Martin KaFai Lau <martin.lau@linux.dev>
To: Jiri Olsa <jolsa@kernel.org>, Kui-Feng Lee <kuifeng@fb.com>
Cc: bpf@vger.kernel.org, Song Liu <songliubraving@fb.com>,
	Yonghong Song <yhs@fb.com>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@chromium.org>,
	Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>
Subject: Re: [PATCH bpf-next] selftests/bpf: Add missing bpf_iter_vma_offset__destroy call
Date: Mon, 3 Oct 2022 17:12:44 -0700	[thread overview]
Message-ID: <49aa0aec-a009-c0c3-cf47-11a6734aae36@linux.dev> (raw)
In-Reply-To: <20221002151141.1074196-1-jolsa@kernel.org>

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@fb.com>
> Signed-off-by: Jiri Olsa <jolsa@kernel.org>
> ---
>   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)


  reply	other threads:[~2022-10-04  0:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-02 15:11 [PATCH bpf-next] selftests/bpf: Add missing bpf_iter_vma_offset__destroy call Jiri Olsa
2022-10-04  0:12 ` Martin KaFai Lau [this message]
2022-10-04  6:38   ` Jiri Olsa
2022-10-04 12:16     ` Jiri Olsa
2022-10-05 22:58       ` Andrii Nakryiko
2022-10-06  7:03         ` Jiri Olsa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=49aa0aec-a009-c0c3-cf47-11a6734aae36@linux.dev \
    --to=martin.lau@linux.dev \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=kpsingh@chromium.org \
    --cc=kuifeng@fb.com \
    --cc=sdf@google.com \
    --cc=songliubraving@fb.com \
    --cc=yhs@fb.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox