[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZpB-dswNvYJiCRR4@mini-arch>
Date: Thu, 11 Jul 2024 17:53:10 -0700
From: Stanislav Fomichev <sdf@...ichev.me>
To: Ma Ke <make24@...as.ac.cn>
Cc: ast@...nel.org, daniel@...earbox.net, andrii@...nel.org,
martin.lau@...ux.dev, eddyz87@...il.com, song@...nel.org,
yonghong.song@...ux.dev, john.fastabend@...il.com,
kpsingh@...nel.org, haoluo@...gle.com, jolsa@...nel.org,
mykolal@...com, shuah@...nel.org, sowmini.varadhan@...cle.com,
bpf@...r.kernel.org, linux-kselftest@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] selftests/bpf:fix a resource leak in main()
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@...as.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.
Powered by blists - more mailing lists