From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by ml01.01.org (Postfix) with ESMTP id 2F59E1A1E68 for ; Mon, 1 Aug 2016 22:38:43 -0700 (PDT) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP; 01 Aug 2016 22:38:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.28,458,1464678000"; d="scan'208";a="857829150" Received: from shwde7172.ccr.corp.intel.com ([10.239.9.23]) by orsmga003.jf.intel.com with ESMTP; 01 Aug 2016 22:38:42 -0700 From: Liming Gao To: edk2-devel@lists.01.org Date: Tue, 2 Aug 2016 13:38:38 +0800 Message-Id: <1470116318-5600-1-git-send-email-liming.gao@intel.com> X-Mailer: git-send-email 2.8.0.windows.1 Subject: [Patch] MdeModulePkg LoadFileOnFv2: Fix the potential NULL pointer access X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 02 Aug 2016 05:38:43 -0000 Check NULL pointer before access it. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Liming Gao --- MdeModulePkg/Universal/LoadFileOnFv2/LoadFileOnFv2.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/MdeModulePkg/Universal/LoadFileOnFv2/LoadFileOnFv2.c b/MdeModulePkg/Universal/LoadFileOnFv2/LoadFileOnFv2.c index 9eea50d..18a07d8 100644 --- a/MdeModulePkg/Universal/LoadFileOnFv2/LoadFileOnFv2.c +++ b/MdeModulePkg/Universal/LoadFileOnFv2/LoadFileOnFv2.c @@ -345,6 +345,9 @@ FvNotificationEvent ( Index = 0; BufferSize = sizeof (EFI_HANDLE); Handle = AllocateZeroPool (BufferSize); + if (Handle == NULL) { + return; + } Status = gBS->LocateHandle ( ByProtocol, &gEfiFirmwareVolume2ProtocolGuid, @@ -355,6 +358,9 @@ FvNotificationEvent ( if (EFI_BUFFER_TOO_SMALL == Status) { FreePool (Handle); Handle = AllocateZeroPool (BufferSize); + if (Handle == NULL) { + return; + } Status = gBS->LocateHandle ( ByProtocol, &gEfiFirmwareVolume2ProtocolGuid, -- 2.8.0.windows.1