summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Bus/Pci/UhciDxe/Uhci.c
diff options
context:
space:
mode:
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2007-11-28 03:55:36 +0000
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>2007-11-28 03:55:36 +0000
commit6a6d955c5f670141344c614c65dbea332f393b57 (patch)
tree80cb86cc7d44521d19279bb917146363376f67f1 /MdeModulePkg/Bus/Pci/UhciDxe/Uhci.c
parentac4f8b5abe6758183102be3feea30c7430eedf3a (diff)
downloadedk2-6a6d955c5f670141344c614c65dbea332f393b57.tar.gz
edk2-6a6d955c5f670141344c614c65dbea332f393b57.tar.bz2
edk2-6a6d955c5f670141344c614c65dbea332f393b57.zip
Fixed potential issues to release resources when error occurs.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@4341 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Bus/Pci/UhciDxe/Uhci.c')
-rw-r--r--MdeModulePkg/Bus/Pci/UhciDxe/Uhci.c25
1 files changed, 15 insertions, 10 deletions
diff --git a/MdeModulePkg/Bus/Pci/UhciDxe/Uhci.c b/MdeModulePkg/Bus/Pci/UhciDxe/Uhci.c
index 82142b6a85..b52510041f 100644
--- a/MdeModulePkg/Bus/Pci/UhciDxe/Uhci.c
+++ b/MdeModulePkg/Bus/Pci/UhciDxe/Uhci.c
@@ -2133,6 +2133,7 @@ UhciDriverBindingStart (
USB_HC_DEV *Uhc;
UINT64 Supports;
UINT64 OriginalPciAttributes;
+ BOOLEAN PciAttributesSaved;
//
// Open PCIIO, then enable the EHC device and turn off emulation
@@ -2151,6 +2152,7 @@ UhciDriverBindingStart (
return Status;
}
+ PciAttributesSaved = FALSE;
//
// Save original PCI attributes
//
@@ -2162,8 +2164,9 @@ UhciDriverBindingStart (
);
if (EFI_ERROR (Status)) {
- return Status;
+ goto CLOSE_PCIIO;
}
+ PciAttributesSaved = TRUE;
UhciTurnOffUsbEmulation (PciIo);
@@ -2262,15 +2265,17 @@ FREE_UHC:
UhciFreeDev (Uhc);
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,