From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (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 B117B21A00AD0 for ; Fri, 23 Jun 2017 03:39:32 -0700 (PDT) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga104.jf.intel.com with ESMTP; 23 Jun 2017 03:40:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,377,1493708400"; d="scan'208";a="118428950" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by fmsmga006.fm.intel.com with ESMTP; 23 Jun 2017 03:40:58 -0700 Received: from fmsmsx155.amr.corp.intel.com (10.18.116.71) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 23 Jun 2017 03:40:58 -0700 Received: from shsmsx104.ccr.corp.intel.com (10.239.4.70) by FMSMSX155.amr.corp.intel.com (10.18.116.71) with Microsoft SMTP Server (TLS) id 14.3.319.2; Fri, 23 Jun 2017 03:40:57 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.146]) by SHSMSX104.ccr.corp.intel.com ([10.239.4.70]) with mapi id 14.03.0319.002; Fri, 23 Jun 2017 18:40:55 +0800 From: "Gao, Liming" To: "Zeng, Star" , "edk2-devel@lists.01.org" Thread-Topic: [PATCH] MdeModulePkg DxeCore: Only free ScratchBuffer when it is not NULL Thread-Index: AQHS7AV5weYP6Hu4y02u2qTopn+0PaIyQk1w Date: Fri, 23 Jun 2017 10:40:55 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14D74E08A@shsmsx102.ccr.corp.intel.com> References: <1498211124-157132-1-git-send-email-star.zeng@intel.com> In-Reply-To: <1498211124-157132-1-git-send-email-star.zeng@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH] MdeModulePkg DxeCore: Only free ScratchBuffer when it is not NULL X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 23 Jun 2017 10:39:32 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Good catch. Reviewed-by: Liming Gao >-----Original Message----- >From: Zeng, Star >Sent: Friday, June 23, 2017 5:45 PM >To: edk2-devel@lists.01.org >Cc: Zeng, Star ; Gao, Liming >Subject: [PATCH] MdeModulePkg DxeCore: Only free ScratchBuffer when it is >not NULL > >There is a case that ExtractGuidedSectionGetInfo return 0 for >ScratchBufferSize and ScratchBuffer will be NULL, after AllocatePool >fails to allocate buffer for AllocatedOutputBuffer, the code will >call FreePool (ScratchBuffer), but ScratchBuffer =3D=3D NULL. > >This patch is to only free ScratchBuffer when it is not NULL. > >Cc: Liming Gao >Contributed-under: TianoCore Contribution Agreement 1.0 >Signed-off-by: Star Zeng >--- > MdeModulePkg/Core/Dxe/SectionExtraction/CoreSectionExtraction.c | 6 >++++-- > 1 file changed, 4 insertions(+), 2 deletions(-) > >diff --git >a/MdeModulePkg/Core/Dxe/SectionExtraction/CoreSectionExtraction.c >b/MdeModulePkg/Core/Dxe/SectionExtraction/CoreSectionExtraction.c >index 6622eeeaf161..9561ae176655 100644 >--- a/MdeModulePkg/Core/Dxe/SectionExtraction/CoreSectionExtraction.c >+++ b/MdeModulePkg/Core/Dxe/SectionExtraction/CoreSectionExtraction.c >@@ -27,7 +27,7 @@ > 3) A support protocol is not found, and the data is not available to be= read > without it. This results in EFI_PROTOCOL_ERROR. > >-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
>+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
> This program and the accompanying materials > are licensed and made available under the terms and conditions of the BSD >License > which accompanies this distribution. The full text of the license may be= found >at >@@ -1551,7 +1551,9 @@ CustomGuidedSectionExtract ( > // > AllocatedOutputBuffer =3D AllocatePool (OutputBufferSize); > if (AllocatedOutputBuffer =3D=3D NULL) { >- FreePool (ScratchBuffer); >+ if (ScratchBuffer !=3D NULL) { >+ FreePool (ScratchBuffer); >+ } > return EFI_OUT_OF_RESOURCES; > } > *OutputBuffer =3D AllocatedOutputBuffer; >-- >2.7.0.windows.1