USB_HC_DEV *Uhc;\r
UINT64 Supports;\r
UINT64 OriginalPciAttributes;\r
+ BOOLEAN PciAttributesSaved;\r
\r
//\r
// Open PCIIO, then enable the EHC device and turn off emulation\r
return Status;\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
UhciTurnOffUsbEmulation (PciIo);\r
\r
UhciFreeDev (Uhc);\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