EFI_PCI_IO_PROTOCOL *PciIo;\r
UINT64 Supports;\r
UINT64 OriginalPciAttributes;\r
+ BOOLEAN PciAttributesSaved;\r
\r
//\r
// Open the PciIo Protocol, then enable the USB host controller\r
return EFI_DEVICE_ERROR;\r
}\r
\r
+ PciAttributesSaved = FALSE;\r
//\r
// Save original PCI attributes\r
//\r
);\r
\r
if (EFI_ERROR (Status)) {\r
- return Status;\r
+ goto CLOSE_PCIIO;\r
}\r
+ PciAttributesSaved = TRUE;\r
\r
Status = PciIo->Attributes (\r
PciIo,\r
gBS->FreePool (Ehc);\r
\r
CLOSE_PCIIO:\r
- //\r
- // Restore original PCI attributes\r
- //\r
- PciIo->Attributes (\r
- PciIo,\r
- EfiPciIoAttributeOperationSet,\r
- OriginalPciAttributes,\r
- NULL\r
- );\r
+ if (PciAttributesSaved == TRUE) {\r
+ //\r
+ // Restore original PCI attributes\r
+ //\r
+ PciIo->Attributes (\r
+ PciIo,\r
+ EfiPciIoAttributeOperationSet,\r
+ OriginalPciAttributes,\r
+ NULL\r
+ );\r
+ }\r
\r
gBS->CloseProtocol (\r
Controller,\r