]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/PciBus: Avoid hang when BUS pad resource is not in top
authorRuiyu Ni <ruiyu.ni@intel.com>
Thu, 27 Jul 2017 03:05:16 +0000 (11:05 +0800)
committerRuiyu Ni <ruiyu.ni@intel.com>
Fri, 28 Jul 2017 09:52:46 +0000 (17:52 +0800)
PciScanBus() assumes the GetResourcePadding() puts BUS descriptor
in the very beginning, if it's not, the Descriptors will be updated
to point to middle of the pool buffer, which can cause
FreePool(Descriptors) hang in DEBUG image.
No functionality impact to RELEASE image.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c

index e1d62e8c21cb6b95e04e274984cddcaa6606e4c2..8b076e87910733a8daf17f730e195a6a1ad1aaac 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Internal library implementation for PCI Bus module.\r
 \r
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
 (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
@@ -986,6 +986,7 @@ PciScanBus (
   UINT64                            PciAddress;\r
   EFI_HPC_PADDING_ATTRIBUTES        Attributes;\r
   EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptors;\r
+  EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *NextDescriptors;\r
   UINT16                            BusRange;\r
   EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL   *PciRootBridgeIo;\r
   BOOLEAN                           BusPadding;\r
@@ -1143,8 +1144,9 @@ PciScanBus (
               }\r
 \r
               BusRange = 0;\r
+              NextDescriptors = Descriptors;\r
               Status = PciGetBusRange (\r
-                        &Descriptors,\r
+                        &NextDescriptors,\r
                         NULL,\r
                         NULL,\r
                         &BusRange\r