From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.136; helo=mga12.intel.com; envelope-from=star.zeng@intel.com; receiver=edk2-devel@lists.01.org Received: from mga12.intel.com (mga12.intel.com [192.55.52.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 79169210C2D66 for ; Thu, 26 Jul 2018 18:00:25 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga106.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Jul 2018 18:00:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,407,1526367600"; d="scan'208";a="243685957" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga005.jf.intel.com with ESMTP; 26 Jul 2018 18:00:20 -0700 Received: from fmsmsx154.amr.corp.intel.com (10.18.116.70) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 26 Jul 2018 17:59:44 -0700 Received: from shsmsx152.ccr.corp.intel.com (10.239.6.52) by FMSMSX154.amr.corp.intel.com (10.18.116.70) with Microsoft SMTP Server (TLS) id 14.3.319.2; Thu, 26 Jul 2018 17:59:41 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.124]) by SHSMSX152.ccr.corp.intel.com ([169.254.6.173]) with mapi id 14.03.0319.002; Fri, 27 Jul 2018 08:57:39 +0800 From: "Zeng, Star" To: Vladimir Olovyannikov , "edk2-devel@lists.01.org" CC: "Zeng, Star" Thread-Topic: [edk2] [PATCH v1] MdeModulePkg: Fix memory leak in FvSimpleFileSystem driver Thread-Index: AQHUJFB3NGL8nKgNs0uQTd3wzXgry6SiQJOQ Date: Fri, 27 Jul 2018 00:57:38 +0000 Message-ID: <0C09AFA07DD0434D9E2A0C6AEB0483103BB890C3@shsmsx102.ccr.corp.intel.com> References: <3f19ff149bc5e3fce4f0d868de07ddb95c123d70.1532547558.git.vladimir.olovyannikov@broadcom.com> In-Reply-To: <3f19ff149bc5e3fce4f0d868de07ddb95c123d70.1532547558.git.vladimir.olovyannikov@broadcom.com> Accept-Language: zh-CN, en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH v1] MdeModulePkg: Fix memory leak in FvSimpleFileSystem driver X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 27 Jul 2018 01:00:25 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Star Zeng and pushed the patch at b5bd3e= d64898db1088a9468446a0d2d0dc7185e8 with changing the title a little to " Md= eModulePkg FvSimpleFileSystemDxe: Fix memory leak in Read function ". Thanks, Star -----Original Message----- From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of Vlad= imir Olovyannikov Sent: Thursday, July 26, 2018 3:48 AM To: edk2-devel@lists.01.org Cc: Vladimir Olovyannikov Subject: [edk2] [PATCH v1] MdeModulePkg: Fix memory leak in FvSimpleFileSys= tem driver FvSimpleFileSystem on read always allocates a FileBuffer, and never frees i= t. 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 --- .../Universal/FvSimpleFileSystemDxe/FvSimpleFileSystem.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSyste= m.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 ( =20 Status =3D FvFsReadFile (File->Instance->FvProtocol, File->FvFileInfo,= &FileSize, &FileBuffer); if (EFI_ERROR (Status)) { + FreePool (FileBuffer); return EFI_DEVICE_ERROR; } =20 @@ -714,6 +715,8 @@ FvSimpleFileSystemRead ( CopyMem (Buffer, (UINT8*)FileBuffer + File->Position, *BufferSize); File->Position +=3D *BufferSize; =20 + 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