All of lore.kernel.org
 help / color / mirror / Atom feed
From: Yonghong Song <yonghong.song@linux.dev>
To: Kery Qi <qikeyu2017@gmail.com>, andrii@kernel.org
Cc: martin.lau@linux.dev, bpf@vger.kernel.org
Subject: Re: [PATCH] selftests/bpf: wq: fix skel leak in serial_test_wq()
Date: Sun, 11 Jan 2026 22:17:14 -0800	[thread overview]
Message-ID: <214576f2-e3a3-400c-a7c8-aa9b0227d5d6@linux.dev> (raw)
In-Reply-To: <20260111183024.2273-1-qikeyu2017@gmail.com>



On 1/11/26 10:30 AM, Kery Qi wrote:
> serial_test_wq() returns early when ASSERT_OK_PTR(wq_skel, "wq_skel_load")
> fails. In that case wq__open_and_load() may still have returned a non-NULL
> skeleton, and the early return skips wq__destroy(), leaking resources and
> triggering ASAN leak reports in selftests runs.
>
> Jump to the common clean_up label instead, so wq__destroy() is executed on
> all exit paths. Also fix the missing semicolon after 'goto clean_up'.
>
> Fixes: 8290dba51910 ("selftests/bpf: wq: add bpf_wq_start() checks")
> Signed-off-by: Kery Qi <qikeyu2017@gmail.com>
> ---
>   tools/testing/selftests/bpf/prog_tests/wq.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/wq.c b/tools/testing/selftests/bpf/prog_tests/wq.c
> index 1dcdeda84853..b32e22876492 100644
> --- a/tools/testing/selftests/bpf/prog_tests/wq.c
> +++ b/tools/testing/selftests/bpf/prog_tests/wq.c
> @@ -17,11 +17,11 @@ void serial_test_wq(void)
>   
>   	wq_skel = wq__open_and_load();
>   	if (!ASSERT_OK_PTR(wq_skel, "wq_skel_load"))
> -		return;
> +		goto clean_up;

This is not correct. There is no 'clean_up' label in the original code.
Also, there is nothing to clean up if wq__open_and_load() failed.

>   
>   	err = wq__attach(wq_skel);
>   	if (!ASSERT_OK(err, "wq_attach"))
> -		goto clean_up
> +		goto clean_up;
>   
>   	prog_fd = bpf_program__fd(wq_skel->progs.test_syscall_array_sleepable);
>   	err = bpf_prog_test_run_opts(prog_fd, &topts);


  reply	other threads:[~2026-01-12  6:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-11 18:30 [PATCH] selftests/bpf: wq: fix skel leak in serial_test_wq() Kery Qi
2026-01-12  6:17 ` Yonghong Song [this message]
  -- strict thread matches above, loose matches on Subject: below --
2026-01-11 17:58 Kery Qi
2026-01-11 18:20 ` bot+bpf-ci
2026-01-13 15:13 ` Mykyta Yatsenko

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=214576f2-e3a3-400c-a7c8-aa9b0227d5d6@linux.dev \
    --to=yonghong.song@linux.dev \
    --cc=andrii@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=qikeyu2017@gmail.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.