From b0489b8f3f276932db8aa7af3680b41574bb09f3 Mon Sep 17 00:00:00 2001 From: Jiewen Yao Date: Tue, 31 Oct 2017 12:07:31 +0800 Subject: Add NULL check for GetPciSegmentInfo() Suggested-by: Michael A Kubacki Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiewen Yao --- .../Pci/Library/PciSegmentInfoLibSimple/PciSegmentInfoLibSimple.c | 7 +++++++ .../MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckPci.c | 3 +++ .../MinPlatformPkg/Test/Library/TestPointCheckLib/PeiCheckPci.c | 3 +++ 3 files changed, 13 insertions(+) diff --git a/Platform/Intel/MinPlatformPkg/Pci/Library/PciSegmentInfoLibSimple/PciSegmentInfoLibSimple.c b/Platform/Intel/MinPlatformPkg/Pci/Library/PciSegmentInfoLibSimple/PciSegmentInfoLibSimple.c index a7e09f16b8..1facc63d01 100644 --- a/Platform/Intel/MinPlatformPkg/Pci/Library/PciSegmentInfoLibSimple/PciSegmentInfoLibSimple.c +++ b/Platform/Intel/MinPlatformPkg/Pci/Library/PciSegmentInfoLibSimple/PciSegmentInfoLibSimple.c @@ -44,6 +44,10 @@ GetPciSegmentInfo ( VOID *Hob; PCI_SEGMENT_INFO *PciSegmentInfo; + if (Count == NULL) { + return NULL; + } + *Count = 1; Hob = GetFirstGuidHob (&mPciSegmentInfoHobGuid); if (Hob != NULL) { @@ -51,6 +55,9 @@ GetPciSegmentInfo ( } else { PciSegmentInfo = BuildGuidHob (&mPciSegmentInfoHobGuid, sizeof(PCI_SEGMENT_INFO)); ASSERT(PciSegmentInfo != NULL); + if (PciSegmentInfo == NULL) { + return NULL; + } PciSegmentInfo->SegmentNumber = 0; PciSegmentInfo->BaseAddress = PcdGet64(PcdPciExpressBaseAddress); PciSegmentInfo->StartBusNumber = 0; diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckPci.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckPci.c index 843b23c1ff..3c7e3e3672 100644 --- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckPci.c +++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/DxeCheckPci.c @@ -404,6 +404,9 @@ TestPointCheckPciBusMaster ( PCI_SEGMENT_INFO *PciSegmentInfo; PciSegmentInfo = GetPciSegmentInfo (&SegmentCount); + if (PciSegmentInfo == NULL) { + return EFI_OUT_OF_RESOURCES; + } Status = EFI_SUCCESS; for (Segment = 0; Segment < SegmentCount; Segment++) { diff --git a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiCheckPci.c b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiCheckPci.c index 631f2bd122..ae07e5425c 100644 --- a/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiCheckPci.c +++ b/Platform/Intel/MinPlatformPkg/Test/Library/TestPointCheckLib/PeiCheckPci.c @@ -37,6 +37,9 @@ TestPointCheckPciBusMaster ( PCI_SEGMENT_INFO *PciSegmentInfo; PciSegmentInfo = GetPciSegmentInfo (&SegmentCount); + if (PciSegmentInfo == NULL) { + return EFI_OUT_OF_RESOURCES; + } Status = EFI_SUCCESS; for (Segment = 0; Segment < SegmentCount; Segment++) { -- cgit v1.2.3