summaryrefslogtreecommitdiffstats
path: root/FatPkg/EnhancedFatDxe
diff options
context:
space:
mode:
authorRuiyu Ni <ruiyu.ni@intel.com>2013-11-22 07:39:02 +0000
committerJordan Justen <jordan.l.justen@intel.com>2016-04-06 23:22:43 -0700
commit9e710bc95e6ac6e8fe2c7814a85e63029e01a4d3 (patch)
treedfefec31a46f50af53ffbd207673fe05a97a066d /FatPkg/EnhancedFatDxe
parent833b5a77a3a8faf5247a609d4edbfec7586c0b85 (diff)
downloadedk2-9e710bc95e6ac6e8fe2c7814a85e63029e01a4d3.tar.gz
edk2-9e710bc95e6ac6e8fe2c7814a85e63029e01a4d3.tar.bz2
edk2-9e710bc95e6ac6e8fe2c7814a85e63029e01a4d3.zip
Fix a bug in the Fat Stop() function which may return EFI_NOT_FOUND when the controller handle doesn't support DiskIo2.
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Reviewed-by: Feng Tian <feng.tian@intel.com> (based on FatPkg commit 3454cf4f33cb3b71ebc19705a4d49f1ff3715611) [jordan.l.justen@intel.com: Use script to relicense to 2-clause BSD] Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jordan Justen <jordan.l.justen@intel.com> Acked-by: Mark Doran <mark.doran@intel.com> Acked-by: Laszlo Ersek <lersek@redhat.com>
Diffstat (limited to 'FatPkg/EnhancedFatDxe')
-rw-r--r--FatPkg/EnhancedFatDxe/Fat.c40
1 files changed, 23 insertions, 17 deletions
diff --git a/FatPkg/EnhancedFatDxe/Fat.c b/FatPkg/EnhancedFatDxe/Fat.c
index a52e6ea828..0dcb3bcb43 100644
--- a/FatPkg/EnhancedFatDxe/Fat.c
+++ b/FatPkg/EnhancedFatDxe/Fat.c
@@ -399,7 +399,9 @@ Returns:
EFI_STATUS Status;
EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *FileSystem;
FAT_VOLUME *Volume;
+ EFI_DISK_IO2_PROTOCOL *DiskIo2;
+ DiskIo2 = NULL;
//
// Get our context back
//
@@ -413,25 +415,29 @@ Returns:
);
if (!EFI_ERROR (Status)) {
- Volume = VOLUME_FROM_VOL_INTERFACE (FileSystem);
- Status = FatAbandonVolume (Volume);
- if (EFI_ERROR (Status)) {
- return Status;
- }
+ Volume = VOLUME_FROM_VOL_INTERFACE (FileSystem);
+ DiskIo2 = Volume->DiskIo2;
+ Status = FatAbandonVolume (Volume);
}
- Status = gBS->CloseProtocol (
- ControllerHandle,
- &gEfiDiskIoProtocolGuid,
- This->DriverBindingHandle,
- ControllerHandle
- );
- Status = gBS->CloseProtocol (
- ControllerHandle,
- &gEfiDiskIo2ProtocolGuid,
- This->DriverBindingHandle,
- ControllerHandle
- );
+ if (!EFI_ERROR (Status)) {
+ if (DiskIo2 != NULL) {
+ Status = gBS->CloseProtocol (
+ ControllerHandle,
+ &gEfiDiskIo2ProtocolGuid,
+ This->DriverBindingHandle,
+ ControllerHandle
+ );
+ ASSERT_EFI_ERROR (Status);
+ }
+ Status = gBS->CloseProtocol (
+ ControllerHandle,
+ &gEfiDiskIoProtocolGuid,
+ This->DriverBindingHandle,
+ ControllerHandle
+ );
+ ASSERT_EFI_ERROR (Status);
+ }
return Status;
}