From: Andrew Clayton Date: Thu, 12 Jul 2012 22:28:47 +0000 (+0100) Subject: file.c: Fix a file descriptor leak in readfile() X-Git-Url: http://git.tdb.fi/?p=ext%2Fsubsurface.git;a=commitdiff_plain;h=7fe652ab5738717ba443ae9de2b8f437103fd71b 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 Signed-off-by: Linus Torvalds --- diff --git a/file.c b/file.c index 538f5c7..e016390 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;