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

@@ -211,7 +211,9 @@ CirrusLogic5430ControllerDriverStart (
{
EFI_STATUS Status;
CIRRUS_LOGIC_5430_PRIVATE_DATA *Private;
BOOLEAN PciAttributesSaved;
PciAttributesSaved = FALSE;
//
// Allocate Private context data for UGA Draw inteface.
//
@@ -255,6 +257,7 @@ CirrusLogic5430ControllerDriverStart (
if (EFI_ERROR (Status)) {
goto Error;
}
PciAttributesSaved = TRUE;
Status = Private->PciIo->Attributes (
Private->PciIo,
@@ -319,16 +322,17 @@ Error:
if (EFI_ERROR (Status)) {
if (Private) {
if (Private->PciIo) {
//
// Restore original PCI attributes
//
Private->PciIo->Attributes (
Private->PciIo,
EfiPciIoAttributeOperationSet,
Private->OriginalPciAttributes,
NULL
);
if (PciAttributesSaved == TRUE) {
//
// Restore original PCI attributes
//
Private->PciIo->Attributes (
Private->PciIo,
EfiPciIoAttributeOperationSet,
Private->OriginalPciAttributes,
NULL
);
}
//
// Close the PCI I/O Protocol
//