X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdeModulePkg%2FBus%2FPci%2FEhciDxe%2FEhci.c;h=e37cf719d7fcb9dc3a2a7a28cacd9b5471949640;hp=32ae6b6cdcfd040f2ef004ab95c55beaf0577535;hb=6a6d955c5f670141344c614c65dbea332f393b57;hpb=ac4f8b5abe6758183102be3feea30c7430eedf3a;ds=sidebyside diff --git a/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c b/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c index 32ae6b6cdc..e37cf719d7 100644 --- a/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c +++ b/MdeModulePkg/Bus/Pci/EhciDxe/Ehci.c @@ -1496,6 +1496,7 @@ EhcDriverBindingStart ( EFI_PCI_IO_PROTOCOL *PciIo; UINT64 Supports; UINT64 OriginalPciAttributes; + BOOLEAN PciAttributesSaved; // // Open the PciIo Protocol, then enable the USB host controller @@ -1514,6 +1515,7 @@ EhcDriverBindingStart ( return EFI_DEVICE_ERROR; } + PciAttributesSaved = FALSE; // // Save original PCI attributes // @@ -1525,8 +1527,9 @@ EhcDriverBindingStart ( ); if (EFI_ERROR (Status)) { - return Status; + goto CLOSE_PCIIO; } + PciAttributesSaved = TRUE; Status = PciIo->Attributes ( PciIo, @@ -1634,15 +1637,17 @@ FREE_POOL: gBS->FreePool (Ehc); CLOSE_PCIIO: - // - // Restore original PCI attributes - // - PciIo->Attributes ( - PciIo, - EfiPciIoAttributeOperationSet, - OriginalPciAttributes, - NULL - ); + if (PciAttributesSaved == TRUE) { + // + // Restore original PCI attributes + // + PciIo->Attributes ( + PciIo, + EfiPciIoAttributeOperationSet, + OriginalPciAttributes, + NULL + ); + } gBS->CloseProtocol ( Controller,