All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [PATCH v1] lib/tst_memutils.c: Fix resource leak
@ 2022-02-11 15:27 Bogdan Lezhepekov via ltp
  2022-02-15 13:04 ` Cyril Hrubis
  0 siblings, 1 reply; 2+ messages in thread
From: Bogdan Lezhepekov via ltp @ 2022-02-11 15:27 UTC (permalink / raw)
  To: ltp

File descriptor was not closed properly
before return.

Signed-off-by: Bogdan Lezhepekov <bogdan.lezhepekov@suse.com>
---
 lib/tst_memutils.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/lib/tst_memutils.c b/lib/tst_memutils.c
index 4a4974761..2e6d7d5fd 100644
--- a/lib/tst_memutils.c
+++ b/lib/tst_memutils.c
@@ -122,7 +122,10 @@ static int write_score(const char *path, int score)
 		return 1;
 
 	if (fprintf(f, "%d", score) <= 0)
+	{
+		fclose(f);
 		return 1;
+	}
 
 	if (fclose(f))
 		return 1;
-- 
2.35.1


-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

* Re: [LTP] [PATCH v1] lib/tst_memutils.c: Fix resource leak
  2022-02-11 15:27 [LTP] [PATCH v1] lib/tst_memutils.c: Fix resource leak Bogdan Lezhepekov via ltp
@ 2022-02-15 13:04 ` Cyril Hrubis
  0 siblings, 0 replies; 2+ messages in thread
From: Cyril Hrubis @ 2022-02-15 13:04 UTC (permalink / raw)
  To: Bogdan Lezhepekov; +Cc: ltp

Hi!
> diff --git a/lib/tst_memutils.c b/lib/tst_memutils.c
> index 4a4974761..2e6d7d5fd 100644
> --- a/lib/tst_memutils.c
> +++ b/lib/tst_memutils.c
> @@ -122,7 +122,10 @@ static int write_score(const char *path, int score)
>  		return 1;
>  
>  	if (fprintf(f, "%d", score) <= 0)
> +	{
> +		fclose(f);
>  		return 1;
> +	}

The coding style is wrong. Please run 'make check' in the respective
directory when the source code located and fix all warnings.

>  	if (fclose(f))
>  		return 1;
> -- 
> 2.35.1
> 
> 
> -- 
> Mailing list info: https://lists.linux.it/listinfo/ltp

-- 
Cyril Hrubis
chrubis@suse.cz

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

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

end of thread, other threads:[~2022-02-15 13:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-11 15:27 [LTP] [PATCH v1] lib/tst_memutils.c: Fix resource leak Bogdan Lezhepekov via ltp
2022-02-15 13:04 ` Cyril Hrubis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.