]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Pci/PciBusDxe/PciDeviceSupport.c
MdeModulePkg/PciBusDxe: Fix small memory leak in FreePciDevice
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / PciBusDxe / PciDeviceSupport.c
index 359b9ded6d6c6ae6d6ba6da29454dafd73aa2978..48cf57a24f8f4cb2347c0cd05b6ac83483729658 100644 (file)
@@ -1,7 +1,8 @@
 /** @file\r
   Supporting functions implementaion for PCI devices management.\r
 \r
-Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
+(C) Copyright 2018 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
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -105,6 +106,10 @@ FreePciDevice (
     FreePool (PciIoDevice->DevicePath);\r
   }\r
 \r
+  if (PciIoDevice->BusNumberRanges != NULL) {\r
+    FreePool (PciIoDevice->BusNumberRanges);\r
+  }\r
+\r
   FreePool (PciIoDevice);\r
 }\r
 \r
@@ -211,7 +216,6 @@ RegisterPciDevice (
   EFI_STATUS          Status;\r
   VOID                *PlatformOpRomBuffer;\r
   UINTN               PlatformOpRomSize;\r
-  UINT8               PciExpressCapRegOffset;\r
   EFI_PCI_IO_PROTOCOL *PciIo;\r
   UINT8               Data8;\r
   BOOLEAN             HasEfiImage;\r
@@ -231,27 +235,13 @@ RegisterPciDevice (
     return Status;\r
   }\r
 \r
-  //\r
-  // Detect if PCI Express Device\r
-  //\r
-  PciExpressCapRegOffset = 0;\r
-  Status = LocateCapabilityRegBlock (\r
-             PciIoDevice,\r
-             EFI_PCI_CAPABILITY_ID_PCIEXP,\r
-             &PciExpressCapRegOffset,\r
-             NULL\r
-             );\r
-  if (!EFI_ERROR (Status)) {\r
-    PciIoDevice->IsPciExp = TRUE;\r
-  }\r
-\r
   //\r
   // Force Interrupt line to "Unknown" or "No Connection"\r
   //\r
   PciIo = &(PciIoDevice->PciIo);\r
   Data8 = PCI_INT_LINE_UNKNOWN;\r
   PciIo->Pci.Write (PciIo, EfiPciIoWidthUint8, 0x3C, 1, &Data8);\r
\r
+\r
   //\r
   // Process OpRom\r
   //\r
@@ -282,7 +272,7 @@ RegisterPciDevice (
           PciIoDevice->BusNumber,\r
           PciIoDevice->DeviceNumber,\r
           PciIoDevice->FunctionNumber,\r
-          (UINT64) (UINTN) PciIoDevice->PciIo.RomImage,\r
+          PciIoDevice->PciIo.RomImage,\r
           PciIoDevice->PciIo.RomSize\r
           );\r
       }\r
@@ -308,10 +298,10 @@ RegisterPciDevice (
           PciIoDevice->BusNumber,\r
           PciIoDevice->DeviceNumber,\r
           PciIoDevice->FunctionNumber,\r
-          (UINT64) (UINTN) PciIoDevice->PciIo.RomImage,\r
+          PciIoDevice->PciIo.RomImage,\r
           PciIoDevice->PciIo.RomSize\r
           );\r
-      }   \r
+      }\r
     }\r
   }\r
 \r
@@ -711,12 +701,7 @@ StartPciDevicesOnBridge (
                              0,\r
                              &Supports\r
                              );\r
-        //\r
-        // By default every bridge's IO and MMIO spaces are enabled.\r
-        // Bridge's Bus Master will be enabled when any device behind it requests\r
-        // to enable Bus Master.\r
-        //\r
-        Supports &= (UINT64) (EFI_PCI_IO_ATTRIBUTE_IO | EFI_PCI_IO_ATTRIBUTE_MEMORY);\r
+        Supports &= (UINT64)EFI_PCI_DEVICE_ENABLE;\r
         PciIoDevice->PciIo.Attributes (\r
                              &(PciIoDevice->PciIo),\r
                              EfiPciIoAttributeOperationEnable,\r
@@ -768,12 +753,7 @@ StartPciDevicesOnBridge (
                              0,\r
                              &Supports\r
                              );\r
-        //\r
-        // By default every bridge's IO and MMIO spaces are enabled.\r
-        // Bridge's Bus Master will be enabled when any device behind it requests\r
-        // to enable Bus Master.\r
-        //\r
-        Supports &= (UINT64) (EFI_PCI_IO_ATTRIBUTE_IO | EFI_PCI_IO_ATTRIBUTE_MEMORY);\r
+        Supports &= (UINT64)EFI_PCI_DEVICE_ENABLE;\r
         PciIoDevice->PciIo.Attributes (\r
                              &(PciIoDevice->PciIo),\r
                              EfiPciIoAttributeOperationEnable,\r