]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Bus/Pci/PciBusDxe/PciCommand.c
MdeModulePkg: Fix PciBus hang issue
[mirror_edk2.git] / MdeModulePkg / Bus / Pci / PciBusDxe / PciCommand.c
index 9f3fcce6f71c4a24167ae9f383172e1cddb7383e..8a8b4b8faca8bc6a42106b3d1e4497a60249b5f6 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   PCI command register operations supporting functions implementation for PCI Bus module.\r
 \r
-Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<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
@@ -200,9 +200,10 @@ LocatePciExpressCapabilityRegBlock (
      OUT UINT32        *NextRegBlock OPTIONAL\r
   )\r
 {\r
-  UINT32  CapabilityPtr;\r
-  UINT32  CapabilityEntry;\r
-  UINT16  CapabilityID;\r
+  EFI_STATUS           Status;\r
+  UINT32               CapabilityPtr;\r
+  UINT32               CapabilityEntry;\r
+  UINT16               CapabilityID;\r
 \r
   //\r
   // To check the capability of this device supports\r
@@ -222,13 +223,16 @@ LocatePciExpressCapabilityRegBlock (
     // Mask it to DWORD alignment per PCI spec\r
     //\r
     CapabilityPtr &= 0xFFC;\r
-    PciIoDevice->PciIo.Pci.Read (\r
-                             &PciIoDevice->PciIo,\r
-                             EfiPciIoWidthUint32,\r
-                             CapabilityPtr,\r
-                             1,\r
-                             &CapabilityEntry\r
-                             );\r
+    Status = PciIoDevice->PciIo.Pci.Read (\r
+                                      &PciIoDevice->PciIo,\r
+                                      EfiPciIoWidthUint32,\r
+                                      CapabilityPtr,\r
+                                      1,\r
+                                      &CapabilityEntry\r
+                                      );\r
+    if (EFI_ERROR (Status)) {\r
+      break;\r
+    }\r
 \r
     CapabilityID = (UINT16) CapabilityEntry;\r
 \r