]> git.tdb.fi Git - ext/subsurface.git/commitdiff
file.c: Fix a file descriptor leak in readfile()
authorAndrew Clayton <andrew@digital-domain.net>
Thu, 12 Jul 2012 22:28:47 +0000 (23:28 +0100)
committerLinus Torvalds <torvalds@linux-foundation.org>
Fri, 13 Jul 2012 01:19:47 +0000 (18:19 -0700)
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

diff --git a/file.c b/file.c
index 538f5c78312c060216726e71492b123e48b93d4b..e0163909e9160f59f1f74ea667e50ec52684ef30 100644 (file)
--- 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;