From: Eduard Zingerman <eddyz87@gmail.com>
To: Ma Ke <make24@iscas.ac.cn>,
ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
martin.lau@linux.dev, song@kernel.org, yonghong.song@linux.dev,
john.fastabend@gmail.com, kpsingh@kernel.org, sdf@fomichev.me,
haoluo@google.com, jolsa@kernel.org, mykolal@fb.com,
shuah@kernel.org
Cc: bpf@vger.kernel.org, linux-kselftest@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] bpf, selftests: fix a resource leak in main()
Date: Thu, 11 Jul 2024 00:52:47 -0700 [thread overview]
Message-ID: <36fade92f6ed872d62c9fadecc88fd3b764a6423.camel@gmail.com> (raw)
In-Reply-To: <20240711074437.2283810-1-make24@iscas.ac.cn>
On Thu, 2024-07-11 at 15:44 +0800, Ma Ke wrote:
> The requested resources should be closed before return in main(), otherwise
> resource leak will occur. Add a check of cgroup_fd and close().
Note: it is better to group related patches to a patch-set.
>
> Fixes: 4939b2847d26 ("bpf, selftests: Use single cgroup helpers for both test_sockmap/progs")
> Signed-off-by: Ma Ke <make24@iscas.ac.cn>
> ---
> tools/testing/selftests/bpf/test_dev_cgroup.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/tools/testing/selftests/bpf/test_dev_cgroup.c b/tools/testing/selftests/bpf/test_dev_cgroup.c
> index adeaf63cb6fa..e97fc061fab2 100644
> --- a/tools/testing/selftests/bpf/test_dev_cgroup.c
> +++ b/tools/testing/selftests/bpf/test_dev_cgroup.c
> @@ -81,5 +81,7 @@ int main(int argc, char **argv)
> cleanup_cgroup_environment();
>
> out:
> + if (cgroup_fd >= 0)
> + close(cgroup_fd);
This is a standalone program, and Linux closes file descriptors on process exit,
why do you think it's necessary to close the fd here?
> return error;
> }
next prev parent reply other threads:[~2024-07-11 7:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-11 7:44 Ma Ke
2024-07-11 7:52 ` Eduard Zingerman [this message]
2024-07-11 7:51 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=36fade92f6ed872d62c9fadecc88fd3b764a6423.camel@gmail.com \
--to=eddyz87@gmail.com \
--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@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=sdf@fomichev.me \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--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
all inboxes | Powered by JetHome®