summaryrefslogtreecommitdiff
path: root/OvmfPkg/SataControllerDxe
diff options
context:
space:
mode:
authorLaszlo Ersek <lersek@redhat.com>2015-09-22 11:18:22 +0000
committerlersek <lersek@Edk2>2015-09-22 11:18:22 +0000
commit379b17965f0fc3fcf542c606ad628856c2504a2e (patch)
tree788842f64ff96f27e71ab6a8eb09ccea2ca928e8 /OvmfPkg/SataControllerDxe
parent12e92a23ada7b20e424e782fe1e2d325c22e161c (diff)
downloadedk2-platforms-379b17965f0fc3fcf542c606ad628856c2504a2e.tar.xz
OvmfPkg: SataControllerDxe: add cascading error handling to Start()
In the next patch we'll add another PCI operation to SataControllerStart(), which, on error, has to be rolled back similarly to other actions already being done in SataControllerStart(). Since that PCI operation won't provide a non-NULL pointer on success, its rollback isn't really suitable for the current error handling in SataControllerStart(). Employ the traditional cascading labels instead. Cc: Alexander Graf <agraf@suse.de> Cc: Reza Jelveh <reza.jelveh@tuhh.de> Cc: Jordan Justen <jordan.l.justen@intel.com> Cc: Hannes Reinecke <hare@suse.de> Cc: Gabriel L. Somlo <somlo@cmu.edu> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Gabriel Somlo <somlo@cmu.edu> Reviewed-by: Jordan Justen <jordan.l.justen@intel.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18527 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'OvmfPkg/SataControllerDxe')
-rw-r--r--OvmfPkg/SataControllerDxe/SataController.c59
1 files changed, 32 insertions, 27 deletions
diff --git a/OvmfPkg/SataControllerDxe/SataController.c b/OvmfPkg/SataControllerDxe/SataController.c
index e5d10e234e..5e7e23b261 100644
--- a/OvmfPkg/SataControllerDxe/SataController.c
+++ b/OvmfPkg/SataControllerDxe/SataController.c
@@ -411,8 +411,7 @@ SataControllerStart (
EFI_OPEN_PROTOCOL_BY_DRIVER
);
if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "SataControllerStart error return status = %r\n", Status));
- return Status;
+ goto Bail;
}
//
@@ -421,7 +420,7 @@ SataControllerStart (
SataPrivateData = AllocateZeroPool (sizeof (EFI_SATA_CONTROLLER_PRIVATE_DATA));
if (SataPrivateData == NULL) {
Status = EFI_OUT_OF_RESOURCES;
- goto Done;
+ goto ClosePciIo;
}
//
@@ -444,7 +443,9 @@ SataControllerStart (
sizeof (PciData.Hdr.ClassCode),
PciData.Hdr.ClassCode
);
- ASSERT_EFI_ERROR (Status);
+ if (EFI_ERROR (Status)) {
+ goto FreeSataPrivateData;
+ }
if (IS_PCI_IDE (&PciData)) {
SataPrivateData->IdeInit.ChannelCount = IDE_MAX_CHANNEL;
@@ -467,19 +468,19 @@ SataControllerStart (
SataPrivateData->DisqualifiedModes = AllocateZeroPool ((sizeof (EFI_ATA_COLLECTIVE_MODE)) * ChannelDeviceCount);
if (SataPrivateData->DisqualifiedModes == NULL) {
Status = EFI_OUT_OF_RESOURCES;
- goto Done;
+ goto FreeSataPrivateData;
}
SataPrivateData->IdentifyData = AllocateZeroPool ((sizeof (EFI_IDENTIFY_DATA)) * ChannelDeviceCount);
if (SataPrivateData->IdentifyData == NULL) {
Status = EFI_OUT_OF_RESOURCES;
- goto Done;
+ goto FreeDisqualifiedModes;
}
SataPrivateData->IdentifyValid = AllocateZeroPool ((sizeof (BOOLEAN)) * ChannelDeviceCount);
if (SataPrivateData->IdentifyValid == NULL) {
Status = EFI_OUT_OF_RESOURCES;
- goto Done;
+ goto FreeIdentifyData;
}
//
@@ -492,31 +493,35 @@ SataControllerStart (
NULL
);
-Done:
if (EFI_ERROR (Status)) {
-
- gBS->CloseProtocol (
- Controller,
- &gEfiPciIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
- if (SataPrivateData != NULL) {
- if (SataPrivateData->DisqualifiedModes != NULL) {
- FreePool (SataPrivateData->DisqualifiedModes);
- }
- if (SataPrivateData->IdentifyData != NULL) {
- FreePool (SataPrivateData->IdentifyData);
- }
- if (SataPrivateData->IdentifyValid != NULL) {
- FreePool (SataPrivateData->IdentifyValid);
- }
- FreePool (SataPrivateData);
- }
+ goto FreeIdentifyValid;
}
DEBUG ((EFI_D_INFO, "SataControllerStart END status = %r\n", Status));
+ return Status;
+
+FreeIdentifyValid:
+ FreePool (SataPrivateData->IdentifyValid);
+
+FreeIdentifyData:
+ FreePool (SataPrivateData->IdentifyData);
+
+FreeDisqualifiedModes:
+ FreePool (SataPrivateData->DisqualifiedModes);
+
+FreeSataPrivateData:
+ FreePool (SataPrivateData);
+
+ClosePciIo:
+ gBS->CloseProtocol (
+ Controller,
+ &gEfiPciIoProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
+Bail:
+ DEBUG ((EFI_D_ERROR, "SataControllerStart error return status = %r\n", Status));
return Status;
}