From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id F25EB21D491B3 for ; Wed, 26 Jul 2017 20:03:36 -0700 (PDT) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga105.fm.intel.com with ESMTP; 26 Jul 2017 20:05:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,418,1496127600"; d="scan'208";a="131781299" Received: from ray-dev.ccr.corp.intel.com ([10.239.9.23]) by fmsmga005.fm.intel.com with ESMTP; 26 Jul 2017 20:05:39 -0700 From: Ruiyu Ni To: edk2-devel@lists.01.org Cc: Star Zeng Date: Thu, 27 Jul 2017 11:05:37 +0800 Message-Id: <20170727030537.51784-1-ruiyu.ni@intel.com> X-Mailer: git-send-email 2.12.2.windows.2 Subject: [PATCH] MdeModulePkg/PciBus: Avoid hang when BUS pad resource is not in top X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Jul 2017 03:03:37 -0000 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 Cc: Star Zeng --- MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c index e1d62e8c21..8b076e8791 100644 --- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c +++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciLib.c @@ -1,7 +1,7 @@ /** @file Internal library implementation for PCI Bus module. -Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2006 - 2017, 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 @@ -986,6 +986,7 @@ PciScanBus ( UINT64 PciAddress; EFI_HPC_PADDING_ATTRIBUTES Attributes; EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *Descriptors; + EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR *NextDescriptors; UINT16 BusRange; EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *PciRootBridgeIo; BOOLEAN BusPadding; @@ -1143,8 +1144,9 @@ PciScanBus ( } BusRange = 0; + NextDescriptors = Descriptors; Status = PciGetBusRange ( - &Descriptors, + &NextDescriptors, NULL, NULL, &BusRange -- 2.12.2.windows.2