Skip to content

Commit

Permalink
file.c: Fix a file descriptor leak in readfile()
Browse files Browse the repository at this point in the history
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
ac000 authored and torvalds committed Jul 13, 2012
1 parent a3ead9f commit 7fe652a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion file.c
Expand Up @@ -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;

Expand Down

0 comments on commit 7fe652a

Please sign in to comment.