[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAEf4BzbudMt+2VS+F7B70X8bniNH4m-Y3P5tTm0zgABYZcA_UA@mail.gmail.com>
Date: Wed, 26 Jun 2024 16:41:11 -0700
From: Andrii Nakryiko <andrii.nakryiko@...il.com>
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,
sdf@...ichev.me, haoluo@...gle.com, jolsa@...nel.org, mykolal@...com,
shuah@...nel.org, bpf@...r.kernel.org, linux-kselftest@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH] selftests/bpf: don't close(-1) in serial_test_fexit_stress()
On Sun, Jun 23, 2024 at 6:18 AM Ma Ke <make24@...as.ac.cn> wrote:
>
> Guard close() with extra link_fd[i] >= 0 and fexit_fd[i] >= 0
> check to prevent close(-1).
>
> Signed-off-by: Ma Ke <make24@...as.ac.cn>
> ---
> tools/testing/selftests/bpf/prog_tests/fexit_stress.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/prog_tests/fexit_stress.c b/tools/testing/selftests/bpf/prog_tests/fexit_stress.c
> index 596536def43d..94ff1d9fc9e4 100644
> --- a/tools/testing/selftests/bpf/prog_tests/fexit_stress.c
> +++ b/tools/testing/selftests/bpf/prog_tests/fexit_stress.c
> @@ -50,9 +50,9 @@ void serial_test_fexit_stress(void)
>
> out:
> for (i = 0; i < bpf_max_tramp_links; i++) {
> - if (link_fd[i])
> + if (link_fd[i] >= 0)
> close(link_fd[i]);
> - if (fexit_fd[i])
> + if (fexit_fd[i] >= 0)
> close(fexit_fd[i]);
bpf_link_create() and bpf_prog_load() will return FDs > 2, so we
should just check > 0 conditions. I fixed it up while applying.
> }
> free(fd);
> --
> 2.25.1
>
Powered by blists - more mailing lists