From: Stanislav Fomichev <sdf@fomichev.me>
To: Ma Ke <make24@iscas.ac.cn>
Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
martin.lau@linux.dev, eddyz87@gmail.com, song@kernel.org,
yonghong.song@linux.dev, john.fastabend@gmail.com,
kpsingh@kernel.org, haoluo@google.com, jolsa@kernel.org,
mykolal@fb.com, shuah@kernel.org, sowmini.varadhan@oracle.com,
bpf@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] selftests/bpf:fix a resource leak in main()
Date: Thu, 11 Jul 2024 17:53:10 -0700 [thread overview]
Message-ID: <ZpB-dswNvYJiCRR4@mini-arch> (raw)
In-Reply-To: <20240711071018.2197252-1-make24@iscas.ac.cn>
On 07/11, Ma Ke wrote:
> The requested resources should be closed before return in main(), otherwise
> resource leak will occur. Add a check of cg_fd before close().
>
> Fixes: 435f90a338ae ("selftests/bpf: add a test case for sock_ops perf-event notification")
> Signed-off-by: Ma Ke <make24@iscas.ac.cn>
> ---
> tools/testing/selftests/bpf/test_tcpnotify_user.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/bpf/test_tcpnotify_user.c b/tools/testing/selftests/bpf/test_tcpnotify_user.c
> index 595194453ff8..f81c60db586e 100644
> --- a/tools/testing/selftests/bpf/test_tcpnotify_user.c
> +++ b/tools/testing/selftests/bpf/test_tcpnotify_user.c
> @@ -161,7 +161,8 @@ int main(int argc, char **argv)
> error = 0;
> err:
> bpf_prog_detach(cg_fd, BPF_CGROUP_SOCK_OPS);
> - close(cg_fd);
Worst case that happens here is that we call close(-1) which returns
EBADFS or something similar. Don't think there is any problem. This
applies to the rest of that patches that add an extra 'if' check.
next prev parent reply other threads:[~2024-07-12 0:53 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-11 7:10 [PATCH] selftests/bpf:fix a resource leak in main() Ma Ke
2024-07-12 0:53 ` Stanislav Fomichev [this message]
2024-07-12 8:05 ` Markus Elfring
2024-07-13 0:59 ` Stanislav Fomichev
-- strict thread matches above, loose matches on Subject: below --
2024-07-11 7:18 Ma Ke
2024-07-11 7:34 Ma Ke
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=ZpB-dswNvYJiCRR4@mini-arch \
--to=sdf@fomichev.me \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=haoluo@google.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kpsingh@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=make24@iscas.ac.cn \
--cc=martin.lau@linux.dev \
--cc=mykolal@fb.com \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=sowmini.varadhan@oracle.com \
--cc=yonghong.song@linux.dev \
/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