public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Zeng, Star" <star.zeng@intel.com>
To: Vladimir Olovyannikov <vladimir.olovyannikov@broadcom.com>,
	"edk2-devel@lists.01.org" <edk2-devel@lists.01.org>
Cc: "Zeng, Star" <star.zeng@intel.com>
Subject: Re: [PATCH v1] MdeModulePkg: Fix memory leak in FvSimpleFileSystem driver
Date: Fri, 27 Jul 2018 00:57:38 +0000	[thread overview]
Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103BB890C3@shsmsx102.ccr.corp.intel.com> (raw)
In-Reply-To: <3f19ff149bc5e3fce4f0d868de07ddb95c123d70.1532547558.git.vladimir.olovyannikov@broadcom.com>

Reviewed-by: Star Zeng <star.zeng@intel.com> and pushed the patch at b5bd3ed64898db1088a9468446a0d2d0dc7185e8 with changing the title a little to " MdeModulePkg FvSimpleFileSystemDxe: Fix memory leak in Read function ".

Thanks,
Star
-----Original Message-----
From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Vladimir Olovyannikov
Sent: Thursday, July 26, 2018 3:48 AM
To: edk2-devel@lists.01.org
Cc: Vladimir Olovyannikov <vladimir.olovyannikov@broadcom.com>
Subject: [edk2] [PATCH v1] MdeModulePkg: Fix memory leak in FvSimpleFileSystem driver

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

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel


      parent reply	other threads:[~2018-07-27  1:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

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=0C09AFA07DD0434D9E2A0C6AEB0483103BB890C3@shsmsx102.ccr.corp.intel.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