diff mbox series

[30/34] fsx: fix leaked log file pointer

Message ID 173870406564.546134.12817088521328536453.stgit@frogsfrogsfrogs (mailing list archive)
State New
Headers show
Series [01/34] generic/476: fix fsstress process management | expand

Commit Message

Darrick J. Wong Feb. 4, 2025, 9:30 p.m. UTC
From: Darrick J. Wong <djwong@kernel.org>

Fix a resource leaks in fsx, where we fail to close the fsx logfile,
because the C library could have some buffered contents that aren't
flushed when the program terminates.  glibc seems to do this for us, but
I wouldn't be so sure about the others.

Fixes: 3f742550dfed84 ("fsx: add support for recording operations to a file")
Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
---
 ltp/fsx.c |    1 +
 1 file changed, 1 insertion(+)

Comments

Dave Chinner Feb. 5, 2025, 12:57 a.m. UTC | #1
On Tue, Feb 04, 2025 at 01:30:07PM -0800, Darrick J. Wong wrote:
> From: Darrick J. Wong <djwong@kernel.org>
> 
> Fix a resource leaks in fsx, where we fail to close the fsx logfile,
> because the C library could have some buffered contents that aren't
> flushed when the program terminates.  glibc seems to do this for us, but
> I wouldn't be so sure about the others.
> 
> Fixes: 3f742550dfed84 ("fsx: add support for recording operations to a file")
> Signed-off-by: "Darrick J. Wong" <djwong@kernel.org>
> ---
>  ltp/fsx.c |    1 +
>  1 file changed, 1 insertion(+)
> 
> 
> diff --git a/ltp/fsx.c b/ltp/fsx.c
> index d1b0f245582b31..163b9453b5418b 100644
> --- a/ltp/fsx.c
> +++ b/ltp/fsx.c
> @@ -3489,6 +3489,7 @@ main(int argc, char **argv)
>  	if (recordops)
>  		logdump();
>  
> +	fclose(fsxlogf);
>  	exit(0);
>  	return 0;
>  }

Looks fine.

Reviewed-by: Dave Chinner <dchinner@redhat.com>
diff mbox series

Patch

diff --git a/ltp/fsx.c b/ltp/fsx.c
index d1b0f245582b31..163b9453b5418b 100644
--- a/ltp/fsx.c
+++ b/ltp/fsx.c
@@ -3489,6 +3489,7 @@  main(int argc, char **argv)
 	if (recordops)
 		logdump();
 
+	fclose(fsxlogf);
 	exit(0);
 	return 0;
 }