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 <[email protected]>
---
 DuetPkg/PciBusNoEnumerationDxe/PciEnumeratorSupport.c | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/DuetPkg/PciBusNoEnumerationDxe/PciEnumeratorSupport.c 
b/DuetPkg/PciBusNoEnumerationDxe/PciEnumeratorSupport.c
index 80b2b6b..6b7dceb 100644
--- a/DuetPkg/PciBusNoEnumerationDxe/PciEnumeratorSupport.c
+++ b/DuetPkg/PciBusNoEnumerationDxe/PciEnumeratorSupport.c
@@ -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)) {
-- 
1.9.1

_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to