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
This commit is contained in:
vanjeff
2007-11-28 03:55:36 +00:00
parent ac4f8b5abe
commit 6a6d955c5f
5 changed files with 291 additions and 266 deletions

View File

@ -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,