summaryrefslogtreecommitdiff
path: root/EmulatorPkg/EmuSimpleFileSystemDxe
diff options
context:
space:
mode:
authorRuiyu Ni <ruiyu.ni@intel.com>2018-08-27 13:22:21 +0800
committerRuiyu Ni <ruiyu.ni@intel.com>2018-08-31 10:40:20 +0800
commit1e57188216b1bf8de3473a0e03e422815f8f53d6 (patch)
tree29e29ce6d63b86b08fc1bb2ac9f0b8d21b9b3802 /EmulatorPkg/EmuSimpleFileSystemDxe
parente01238946cbd16f2dfccd7ec86aebe20d7408586 (diff)
downloadedk2-1e57188216b1bf8de3473a0e03e422815f8f53d6.zip
edk2-1e57188216b1bf8de3473a0e03e422815f8f53d6.tar.gz
edk2-1e57188216b1bf8de3473a0e03e422815f8f53d6.tar.bz2
EmulatorPkg: IoThunk->Close() is called too early, may causing hang
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1121 To produce a EFI_BLOCK_IO_PROTOCOL instance in Emulator platform, EmulatorPkg defines the EMU_IO_THUNK_PROTOCOL. OS dependent layer needs to produce this protocol implementation and a generic OS independent layer consumes this protocol to produce EFI_BLOCK_IO_PROTOCOL. EMU_IO_THUNK_PROTOCOL can also be used to abstract the OS dependent IO operation for other UEFI protocols, e.g.: GOP, SimpleFileSystem and etc. It contains two interfaces Open() and Close(). Open() creates the specific IO instances, e.g. for Block IO access, File System access, Screen access, etc. Close() destroys the specific IO instances. Later on the Emulator generic module (e.g.: EmuBlockIoDxe) calls Open() to create the IO instance in DriverBindingStart() and calls Close() in DriverBindingStop(). But today's implementation of DriverBindingStop() contains a bug that it calls Close() before uninstalling the EFI_BLOCK_IO_PROTOCOL. It's a mistake in code. Take EFI_BLOCK_IO for example, the uninstallation may cause the upper layer driver that consumes EFI_BLOCK_IO call BlockIo.Reset(), which consequently calls EmuBlockIo.Reset(). But the EmuBlockIo instance is already destroyed by Close() that happens before uninstallation. So a proper implementation is to call Close() after uninstallation succeeds. REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1121 Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com> Cc: Andrew Fish <afish@apple.com> Reviewed-by: Hao Wu <hao.a.wu@intel.com>
Diffstat (limited to 'EmulatorPkg/EmuSimpleFileSystemDxe')
-rw-r--r--EmulatorPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystem.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/EmulatorPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystem.c b/EmulatorPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystem.c
index b5e19bb..28abfd6 100644
--- a/EmulatorPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystem.c
+++ b/EmulatorPkg/EmuSimpleFileSystemDxe/EmuSimpleFileSystem.c
@@ -866,7 +866,6 @@ EmuSimpleFileSystemDriverBindingStop (
}
Private = EMU_SIMPLE_FILE_SYSTEM_PRIVATE_DATA_FROM_THIS (SimpleFileSystem);
- Status = Private->IoThunk->Close (Private->IoThunk);
//
// Uninstall the Simple File System Protocol from ControllerHandle
@@ -883,9 +882,12 @@ EmuSimpleFileSystemDriverBindingStop (
This->DriverBindingHandle,
ControllerHandle
);
- }
-
- if (!EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ //
+ // Destroy the IO interface.
+ //
+ Status = Private->IoThunk->Close (Private->IoThunk);
+ ASSERT_EFI_ERROR (Status);
//
// Free our instance data
//