From 7fe652ab5738717ba443ae9de2b8f437103fd71b Mon Sep 17 00:00:00 2001 From: Andrew Clayton Date: Thu, 12 Jul 2012 23:28:47 +0100 Subject: [PATCH] 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 --- file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; -- 2.43.0