From nobody Thu May 2 22:13:27 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1498211133502946.9035747983573; Fri, 23 Jun 2017 02:45:33 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 361DA21A00AD2; Fri, 23 Jun 2017 02:44:03 -0700 (PDT) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (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 2ABE121A00ACF for ; Fri, 23 Jun 2017 02:44:02 -0700 (PDT) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga105.fm.intel.com with ESMTP; 23 Jun 2017 02:45:27 -0700 Received: from shwdeopenpsi068.ccr.corp.intel.com ([10.239.9.2]) by fmsmga006.fm.intel.com with ESMTP; 23 Jun 2017 02:45:26 -0700 X-Original-To: edk2-devel@lists.01.org X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.39,377,1493708400"; d="scan'208";a="118414790" From: Star Zeng To: edk2-devel@lists.01.org Date: Fri, 23 Jun 2017 17:45:24 +0800 Message-Id: <1498211124-157132-1-git-send-email-star.zeng@intel.com> X-Mailer: git-send-email 2.7.0.windows.1 Subject: [edk2] [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: , Cc: Liming Gao , Star Zeng MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" 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. =20 -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; --=20 2.7.0.windows.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel