public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] x86: boot/compressed fix resource leak
@ 2011-05-31  9:50 Andre Bartke
  0 siblings, 0 replies; only message in thread
From: Andre Bartke @ 2011-05-31  9:50 UTC (permalink / raw)
  To: tglx; +Cc: x86, linux-kernel, Andre Bartke

In case fread() fails, we should call fclose
and release the resource properly. Also while at it,
fixed brace coding style issue.

Signed-off-by: Andre Bartke <andre.bartke@gmail.com>
---
 arch/x86/boot/compressed/mkpiggy.c |    5 ++---
 1 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/arch/x86/boot/compressed/mkpiggy.c b/arch/x86/boot/compressed/mkpiggy.c
index 46a8238..33b85be 100644
--- a/arch/x86/boot/compressed/mkpiggy.c
+++ b/arch/x86/boot/compressed/mkpiggy.c
@@ -58,13 +58,12 @@ int main(int argc, char *argv[])
 		return 1;
 	}
 
-
-	if (fseek(f, -4L, SEEK_END)) {
+	if (fseek(f, -4L, SEEK_END))
 		perror(argv[1]);
-	}
 
 	if (fread(&olen, sizeof(olen), 1, f) != 1) {
 		perror(argv[1]);
+		fclose(f);
 		return 1;
 	}
 
-- 
1.7.5.2


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2011-05-31  9:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-31  9:50 [PATCH] x86: boot/compressed fix resource leak Andre Bartke

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