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>
This commit is contained in:
Andrew Clayton 2012-07-12 23:28:47 +01:00 committed by Linus Torvalds
parent a3ead9fb86
commit 7fe652ab57

2
file.c
View file

@ -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;