public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Vladimir Olovyannikov <vladimir.olovyannikov@broadcom.com>
To: edk2-devel@lists.01.org
Cc: Vladimir Olovyannikov <vladimir.olovyannikov@broadcom.com>
Subject: [PATCH v1] MdeModulePkg: Fix memory leak in FvSimpleFileSystem driver
Date: Wed, 25 Jul 2018 12:47:49 -0700	[thread overview]
Message-ID: <3f19ff149bc5e3fce4f0d868de07ddb95c123d70.1532547558.git.vladimir.olovyannikov@broadcom.com> (raw)

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



             reply	other threads:[~2018-07-25 19:48 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-25 19:47 Vladimir Olovyannikov [this message]
2018-07-26 15:52 ` [PATCH v1] MdeModulePkg: Fix memory leak in FvSimpleFileSystem driver Ard Biesheuvel
2018-07-27  0:57 ` Zeng, Star

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3f19ff149bc5e3fce4f0d868de07ddb95c123d70.1532547558.git.vladimir.olovyannikov@broadcom.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox