summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Bus/Usb
diff options
context:
space:
mode:
authoreric_tian <eric_tian@6f19259b-4bc3-4df7-8a09-765794883524>2009-08-19 02:32:56 +0000
committereric_tian <eric_tian@6f19259b-4bc3-4df7-8a09-765794883524>2009-08-19 02:32:56 +0000
commit73f8ef8c086a60391647259dfcd853ab30b7b995 (patch)
tree3673d0323db37c616a1d3fb2bc7f148d05b67121 /MdeModulePkg/Bus/Usb
parentb635c7684e7002d836dc9a866ce5cbab9e513481 (diff)
downloadedk2-platforms-73f8ef8c086a60391647259dfcd853ab30b7b995.tar.xz
add error handler in return places.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9119 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg/Bus/Usb')
-rw-r--r--MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassImpl.c67
1 files changed, 51 insertions, 16 deletions
diff --git a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassImpl.c b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassImpl.c
index f80895bda4..2db5f11c63 100644
--- a/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassImpl.c
+++ b/MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassImpl.c
@@ -712,12 +712,14 @@ ON_ERROR:
if (UsbMass != NULL) {
FreePool (UsbMass);
}
- gBS->CloseProtocol (
- Controller,
- &gEfiUsbIoProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ if (UsbIo != NULL) {
+ gBS->CloseProtocol (
+ Controller,
+ &gEfiUsbIoProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
+ }
return Status;
}
@@ -830,6 +832,7 @@ USBMassDriverBindingStart (
VOID *Context;
UINT8 MaxLun;
EFI_STATUS Status;
+ EFI_USB_IO_PROTOCOL *UsbIo;
Transport = NULL;
Context = NULL;
@@ -867,18 +870,44 @@ USBMassDriverBindingStart (
return Status;
}
+ Status = gBS->OpenProtocol (
+ Controller,
+ &gEfiUsbIoProtocolGuid,
+ (VOID **) &UsbIo,
+ This->DriverBindingHandle,
+ Controller,
+ EFI_OPEN_PROTOCOL_BY_DRIVER
+ );
+
+ if (EFI_ERROR (Status)) {
+ DEBUG ((EFI_D_ERROR, "USBMassDriverBindingStart: OpenUsbIoProtocol By Driver (%r)\n", Status));
+ gBS->CloseProtocol (
+ Controller,
+ &gEfiDevicePathProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
+ return Status;
+ }
+
//
// Initialize data for device that supports multiple LUNSs.
// EFI_SUCCESS is returned if at least 1 LUN is initialized successfully.
//
Status = UsbMassInitMultiLun (This, Controller, Transport, Context, DevicePath, MaxLun);
if (EFI_ERROR (Status)) {
- gBS->CloseProtocol (
- Controller,
- &gEfiDevicePathProtocolGuid,
- This->DriverBindingHandle,
- Controller
- );
+ gBS->CloseProtocol (
+ Controller,
+ &gEfiDevicePathProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
+ gBS->CloseProtocol (
+ Controller,
+ &gEfiUsbIoProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
DEBUG ((EFI_D_ERROR, "USBMassDriverBindingStart: UsbMassInitMultiLun (%r) with Maxlun=%d\n", Status, MaxLun));
}
}
@@ -919,9 +948,9 @@ USBMassDriverBindingStop (
//
// This is a bus driver stop function since multi-lun is supported.
// There are three kinds of device handles that might be passed:
- // 1st is a handle with Device Path & USB I/O & Block I/O installed (non-multi-lun)
+ // 1st is a handle with USB I/O & Block I/O installed (non-multi-lun)
// 2nd is a handle with Device Path & USB I/O installed (multi-lun root)
- // 3rd is a handle with Device Path & Block I/O installed (multi-lun).
+ // 3rd is a handle with Device Path & USB I/O & Block I/O installed (multi-lun).
//
if (NumberOfChildren == 0) {
//
@@ -938,8 +967,8 @@ USBMassDriverBindingStop (
if (EFI_ERROR(Status)) {
//
- // This is a 2nd type handle(multi-lun root), which only needs to close
- // Device Path Protocol.
+ // This is a 2nd type handle(multi-lun root), it needs to close devicepath
+ // and usbio protocol.
//
gBS->CloseProtocol (
Controller,
@@ -947,6 +976,12 @@ USBMassDriverBindingStop (
This->DriverBindingHandle,
Controller
);
+ gBS->CloseProtocol (
+ Controller,
+ &gEfiUsbIoProtocolGuid,
+ This->DriverBindingHandle,
+ Controller
+ );
DEBUG ((EFI_D_INFO, "Success to stop multi-lun root handle\n"));
return EFI_SUCCESS;
}