linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Documentation: connector: ucon.c:  Cleaning up file resource leak
@ 2014-05-30 23:46 Rickard Strandqvist
  2014-06-03 22:55 ` Randy Dunlap
  0 siblings, 1 reply; 2+ messages in thread
From: Rickard Strandqvist @ 2014-05-30 23:46 UTC (permalink / raw)
  To: Randy Dunlap, Rickard Strandqvist
  Cc: David S. Miller, Mathias Krause, linux-doc, linux-kernel

Cleaning up a file resource leak

Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
---
 Documentation/connector/ucon.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/connector/ucon.c b/Documentation/connector/ucon.c
index 8a4da64..f09c6de 100644
--- a/Documentation/connector/ucon.c
+++ b/Documentation/connector/ucon.c
@@ -246,5 +246,7 @@ int main(int argc, char *argv[])
 	}
 
 	close(s);
+	if (stdout != out)
+		fclose(out);
 	return 0;
 }
-- 
1.7.10.4


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

* Re: [PATCH] Documentation: connector: ucon.c:  Cleaning up file resource leak
  2014-05-30 23:46 [PATCH] Documentation: connector: ucon.c: Cleaning up file resource leak Rickard Strandqvist
@ 2014-06-03 22:55 ` Randy Dunlap
  0 siblings, 0 replies; 2+ messages in thread
From: Randy Dunlap @ 2014-06-03 22:55 UTC (permalink / raw)
  To: Rickard Strandqvist
  Cc: David S. Miller, Mathias Krause, linux-doc, linux-kernel

On 05/30/2014 04:46 PM, Rickard Strandqvist wrote:
> Cleaning up a file resource leak

The return (exit) closes all open files, so there is no resource leak.

OTOH, if someone were going to add this explicit close, then it should
be added in the other exit (return) paths also.

Not applied by the Documentation maintainer.

> Signed-off-by: Rickard Strandqvist <rickard_strandqvist@spectrumdigital.se>
> ---
>  Documentation/connector/ucon.c |    2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/Documentation/connector/ucon.c b/Documentation/connector/ucon.c
> index 8a4da64..f09c6de 100644
> --- a/Documentation/connector/ucon.c
> +++ b/Documentation/connector/ucon.c
> @@ -246,5 +246,7 @@ int main(int argc, char *argv[])
>  	}
>  
>  	close(s);
> +	if (stdout != out)
> +		fclose(out);
>  	return 0;
>  }
> 


-- 
~Randy

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

end of thread, other threads:[~2014-06-03 22:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-30 23:46 [PATCH] Documentation: connector: ucon.c: Cleaning up file resource leak Rickard Strandqvist
2014-06-03 22:55 ` Randy Dunlap

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).