public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH v1] MdeModulePkg: Fix memory leak in FvSimpleFileSystem driver
@ 2018-07-25 19:47 Vladimir Olovyannikov
  2018-07-26 15:52 ` Ard Biesheuvel
  2018-07-27  0:57 ` Zeng, Star
  0 siblings, 2 replies; 3+ messages in thread
From: Vladimir Olovyannikov @ 2018-07-25 19:47 UTC (permalink / raw)
  To: edk2-devel; +Cc: Vladimir Olovyannikov

FvSimpleFileSystem on read always allocates a FileBuffer, and never frees
it. This causes memory leaks. It is especially bad for reading scripts
line-by-line. In some cases memory leak can exceed 1GB.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Vladimir Olovyannikiov <vladimir.olovyannikov@broadcom.com>
---
 .../Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c       | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c b/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c
index 746f2ced708a..fde208594737 100644
--- a/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c
+++ b/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c
@@ -704,6 +704,7 @@ FvSimpleFileSystemRead (
 
     Status = FvFsReadFile (File->Instance->FvProtocol, File->FvFileInfo, &FileSize, &FileBuffer);
     if (EFI_ERROR (Status)) {
+      FreePool (FileBuffer);
       return EFI_DEVICE_ERROR;
     }
 
@@ -714,6 +715,8 @@ FvSimpleFileSystemRead (
     CopyMem (Buffer, (UINT8*)FileBuffer + File->Position, *BufferSize);
     File->Position += *BufferSize;
 
+    FreePool (FileBuffer);
+
     return EFI_SUCCESS;
   }
 }
-- 
2.18.0



^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-07-27  1:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-25 19:47 [PATCH v1] MdeModulePkg: Fix memory leak in FvSimpleFileSystem driver Vladimir Olovyannikov
2018-07-26 15:52 ` Ard Biesheuvel
2018-07-27  0:57 ` Zeng, Star

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox