The Linux Kernel Mailing List
 help / color / mirror / Atom feed
* [PATCH] tools: firewire: nosy-dump: fix a resource leak in main()
@ 2017-09-13 18:21 Martin Kepplinger
  2017-09-26  7:35 ` Stefan Richter
  0 siblings, 1 reply; 2+ messages in thread
From: Martin Kepplinger @ 2017-09-13 18:21 UTC (permalink / raw)
  To: stefanr; +Cc: linux1394-devel, linux-kernel, Martin Kepplinger

If option_input and option_output is true two files are opened
consecutively. In case the second fopen() fails, let's fclose()
the first one before returning early.

Signed-off-by: Martin Kepplinger <martink@posteo.de>
---
 tools/firewire/nosy-dump.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/firewire/nosy-dump.c b/tools/firewire/nosy-dump.c
index 3179c711bd65..228be406f206 100644
--- a/tools/firewire/nosy-dump.c
+++ b/tools/firewire/nosy-dump.c
@@ -960,6 +960,8 @@ int main(int argc, const char *argv[])
 		output = fopen(option_output, "w");
 		if (output == NULL) {
 			fprintf(stderr, "Could not open %s, %m\n", option_output);
+			if (input)
+				fclose(input);
 			return -1;
 		}
 	}
-- 
2.11.0

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

end of thread, other threads:[~2017-09-26  7:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-13 18:21 [PATCH] tools: firewire: nosy-dump: fix a resource leak in main() Martin Kepplinger
2017-09-26  7:35 ` Stefan Richter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox