Permalink
Browse files

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>
  • Loading branch information...
1 parent a3ead9f commit 7fe652ab5738717ba443ae9de2b8f437103fd71b @ac000 ac000 committed with Jul 12, 2012
Showing with 1 addition and 1 deletion.
  1. +1 −1 file.c
View
@@ -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;

0 comments on commit 7fe652a

Please sign in to comment.