From 7fe652ab5738717ba443ae9de2b8f437103fd71b Mon Sep 17 00:00:00 2001
From: Andrew Clayton <andrew@digital-domain.net>
Date: Thu, 12 Jul 2012 23:28:47 +0100
Subject: [PATCH] file.c: Fix a file descriptor leak in readfile()

In file.c::readfile() the file was being opened once at fd declaration
time and then again a few lines later and only being closed once. Remove
the open() at fd declaration time leaving the later one where the fd check
is done.

Signed-off-by: Andrew Clayton <andrew@digital-domain.net>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
---
 file.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/file.c b/file.c
index 538f5c783..e0163909e 100644
--- a/file.c
+++ b/file.c
@@ -10,7 +10,7 @@
 
 static int readfile(const char *filename, struct memblock *mem)
 {
-	int ret, fd = open(filename, O_RDONLY);
+	int ret, fd;
 	struct stat st;
 	char *buf;