From ba33c80fc594404872bc6f33e48d38836e9384a0 Mon Sep 17 00:00:00 2001 From: Lee Leahy Date: Fri, 26 Feb 2016 10:07:51 +0800 Subject: DuetPkg-PciBusNoEnumerationDxe: Fix stack overflow When a PCI bridge is not enabled, the secondary bus may still be zero. This causes an infinite recursive call to enumerate bus 0 which results in a stack overflow. The easy fix is to skip the recursive bus enumeration for bridges which do not have the secondary bus initialized. TEST=Build and run CorebootPayloadPkg on Quark/Galileo Gen2 Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Lee Leahy Reviewed-by: Ruiyu Ni --- DuetPkg/PciBusNoEnumerationDxe/PciEnumeratorSupport.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'DuetPkg') diff --git a/DuetPkg/PciBusNoEnumerationDxe/PciEnumeratorSupport.c b/DuetPkg/PciBusNoEnumerationDxe/PciEnumeratorSupport.c index 80b2b6b24d..ca300cf675 100644 --- a/DuetPkg/PciBusNoEnumerationDxe/PciEnumeratorSupport.c +++ b/DuetPkg/PciBusNoEnumerationDxe/PciEnumeratorSupport.c @@ -1,6 +1,6 @@ /*++ -Copyright (c) 2005 - 2014, Intel Corporation. All rights reserved.
+Copyright (c) 2005 - 2016, Intel Corporation. All rights reserved.
(C) Copyright 2015 Hewlett Packard Enterprise Development LP
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License @@ -257,13 +257,14 @@ Returns: } // - // Deep enumerate the next level bus + // If the PCI bridge is initialized then enumerate the next level bus // - Status = PciPciDeviceInfoCollector ( - PciIoDevice, - (UINT8) (SecBus) - ); - + if (SecBus != 0) { + Status = PciPciDeviceInfoCollector ( + PciIoDevice, + (UINT8) (SecBus) + ); + } } if (Func == 0 && !IS_PCI_MULTI_FUNC (&Pci)) { -- cgit v1.2.3