bpf.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] selftests/bpf: fix fclose/pclose mismatch
@ 2021-10-26 14:34 Andrea Righi
  2021-10-26 17:47 ` Shuah Khan
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Andrea Righi @ 2021-10-26 14:34 UTC (permalink / raw)
  To: Shuah Khan; +Cc: linux-kselftest, bpf, linux-kernel

Make sure to use pclose() to properly close the pipe opened by popen().

Fixes: 81f77fd0deeb ("bpf: add selftest for stackmap with BPF_F_STACK_BUILD_ID")
Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
---
 tools/testing/selftests/bpf/test_progs.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c
index cc1cd240445d..e3fea6f281e4 100644
--- a/tools/testing/selftests/bpf/test_progs.c
+++ b/tools/testing/selftests/bpf/test_progs.c
@@ -370,7 +370,7 @@ int extract_build_id(char *build_id, size_t size)
 
 	if (getline(&line, &len, fp) == -1)
 		goto err;
-	fclose(fp);
+	pclose(fp);
 
 	if (len > size)
 		len = size;
@@ -379,7 +379,7 @@ int extract_build_id(char *build_id, size_t size)
 	free(line);
 	return 0;
 err:
-	fclose(fp);
+	pclose(fp);
 	return -1;
 }
 
-- 
2.32.0


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] selftests/bpf: fix fclose/pclose mismatch
  2021-10-26 14:34 [PATCH] selftests/bpf: fix fclose/pclose mismatch Andrea Righi
@ 2021-10-26 17:47 ` Shuah Khan
  2021-10-26 17:54   ` Alexei Starovoitov
  2021-10-29  4:56 ` Martin KaFai Lau
  2021-10-29 15:50 ` patchwork-bot+netdevbpf
  2 siblings, 1 reply; 5+ messages in thread
From: Shuah Khan @ 2021-10-26 17:47 UTC (permalink / raw)
  To: Andrea Righi, Shuah Khan, Daniel Borkmann, Alexei Starovoitov,
	Andrii Nakryiko
  Cc: linux-kselftest, bpf, linux-kernel, Shuah Khan

On 10/26/21 8:34 AM, Andrea Righi wrote:
> Make sure to use pclose() to properly close the pipe opened by popen().
> 
> Fixes: 81f77fd0deeb ("bpf: add selftest for stackmap with BPF_F_STACK_BUILD_ID")
> Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
> ---
>   tools/testing/selftests/bpf/test_progs.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c
> index cc1cd240445d..e3fea6f281e4 100644
> --- a/tools/testing/selftests/bpf/test_progs.c
> +++ b/tools/testing/selftests/bpf/test_progs.c
> @@ -370,7 +370,7 @@ int extract_build_id(char *build_id, size_t size)
>   
>   	if (getline(&line, &len, fp) == -1)
>   		goto err;
> -	fclose(fp);
> +	pclose(fp);
>   
>   	if (len > size)
>   		len = size;
> @@ -379,7 +379,7 @@ int extract_build_id(char *build_id, size_t size)
>   	free(line);
>   	return 0;
>   err:
> -	fclose(fp);
> +	pclose(fp);
>   	return -1;
>   }
>   
> 

Thank you for the patch. The return logic could be simpler
doing out handling common for error and success path with
just one call to close. Not related to this change though.

Adding bpf maintainers to the thread

Reviewed-by: Shuah Khan <skhan@linuxfoundation.org>

thanks,
-- Shuah

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] selftests/bpf: fix fclose/pclose mismatch
  2021-10-26 17:47 ` Shuah Khan
@ 2021-10-26 17:54   ` Alexei Starovoitov
  0 siblings, 0 replies; 5+ messages in thread
From: Alexei Starovoitov @ 2021-10-26 17:54 UTC (permalink / raw)
  To: Shuah Khan
  Cc: Andrea Righi, Shuah Khan, Daniel Borkmann, Alexei Starovoitov,
	Andrii Nakryiko, open list:KERNEL SELFTEST FRAMEWORK, bpf, LKML

On Tue, Oct 26, 2021 at 10:47 AM Shuah Khan <skhan@linuxfoundation.org> wrote:
>
> On 10/26/21 8:34 AM, Andrea Righi wrote:
> > Make sure to use pclose() to properly close the pipe opened by popen().
> >
> > Fixes: 81f77fd0deeb ("bpf: add selftest for stackmap with BPF_F_STACK_BUILD_ID")
> > Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
> > ---
> >   tools/testing/selftests/bpf/test_progs.c | 4 ++--
> >   1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/tools/testing/selftests/bpf/test_progs.c b/tools/testing/selftests/bpf/test_progs.c
> > index cc1cd240445d..e3fea6f281e4 100644
> > --- a/tools/testing/selftests/bpf/test_progs.c
> > +++ b/tools/testing/selftests/bpf/test_progs.c
> > @@ -370,7 +370,7 @@ int extract_build_id(char *build_id, size_t size)
> >
> >       if (getline(&line, &len, fp) == -1)
> >               goto err;
> > -     fclose(fp);
> > +     pclose(fp);
> >
> >       if (len > size)
> >               len = size;
> > @@ -379,7 +379,7 @@ int extract_build_id(char *build_id, size_t size)
> >       free(line);
> >       return 0;
> >   err:
> > -     fclose(fp);
> > +     pclose(fp);
> >       return -1;
> >   }
> >
> >
>
> Thank you for the patch. The return logic could be simpler
> doing out handling common for error and success path with
> just one call to close. Not related to this change though.
>
> Adding bpf maintainers to the thread

Ohh. That's odd.
I see the patch in:
https://patchwork.kernel.org/project/netdevbpf/list/?delegate=121173
but not in my gmail.
vger is probably slow.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] selftests/bpf: fix fclose/pclose mismatch
  2021-10-26 14:34 [PATCH] selftests/bpf: fix fclose/pclose mismatch Andrea Righi
  2021-10-26 17:47 ` Shuah Khan
@ 2021-10-29  4:56 ` Martin KaFai Lau
  2021-10-29 15:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 5+ messages in thread
From: Martin KaFai Lau @ 2021-10-29  4:56 UTC (permalink / raw)
  To: Andrea Righi; +Cc: Shuah Khan, linux-kselftest, bpf, linux-kernel

On Tue, Oct 26, 2021 at 04:34:09PM +0200, Andrea Righi wrote:
> Make sure to use pclose() to properly close the pipe opened by popen().
Acked-by: Martin KaFai Lau <kafai@fb.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] selftests/bpf: fix fclose/pclose mismatch
  2021-10-26 14:34 [PATCH] selftests/bpf: fix fclose/pclose mismatch Andrea Righi
  2021-10-26 17:47 ` Shuah Khan
  2021-10-29  4:56 ` Martin KaFai Lau
@ 2021-10-29 15:50 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2021-10-29 15:50 UTC (permalink / raw)
  To: Andrea Righi; +Cc: shuah, linux-kselftest, bpf, linux-kernel

Hello:

This patch was applied to bpf/bpf-next.git (master)
by Daniel Borkmann <daniel@iogearbox.net>:

On Tue, 26 Oct 2021 16:34:09 +0200 you wrote:
> Make sure to use pclose() to properly close the pipe opened by popen().
> 
> Fixes: 81f77fd0deeb ("bpf: add selftest for stackmap with BPF_F_STACK_BUILD_ID")
> Signed-off-by: Andrea Righi <andrea.righi@canonical.com>
> ---
>  tools/testing/selftests/bpf/test_progs.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Here is the summary with links:
  - selftests/bpf: fix fclose/pclose mismatch
    https://git.kernel.org/bpf/bpf-next/c/f48ad69097fe

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-10-29 15:50 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-26 14:34 [PATCH] selftests/bpf: fix fclose/pclose mismatch Andrea Righi
2021-10-26 17:47 ` Shuah Khan
2021-10-26 17:54   ` Alexei Starovoitov
2021-10-29  4:56 ` Martin KaFai Lau
2021-10-29 15:50 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).