From 69fa9171637019d22d834825f4a81f4b9da7c815 Mon Sep 17 00:00:00 2001 From: Hao Wu Date: Wed, 23 Dec 2015 01:36:07 +0000 Subject: MdePkg UefiScsiLib: Close event when SCSI command fails The ScsiExecuteSCSICommand() function in ScsiBusDxe driver will not signal the event passed from UefiScsiLib when error occurs. In this case, UefiScsiLib should close the event passing to ScsiExecuteSCSICommand(). (Sync patch r19448 from main trunk.) Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu Reviewed-by: Feng Tian git-svn-id: https://svn.code.sf.net/p/edk2/code/branches/UDK2015@19469 6f19259b-4bc3-4df7-8a09-765794883524 --- MdePkg/Library/UefiScsiLib/UefiScsiLib.c | 48 +++++++++++++++++++++++++++++--- 1 file changed, 44 insertions(+), 4 deletions(-) (limited to 'MdePkg') diff --git a/MdePkg/Library/UefiScsiLib/UefiScsiLib.c b/MdePkg/Library/UefiScsiLib/UefiScsiLib.c index d8babcee40..0a08e4468e 100644 --- a/MdePkg/Library/UefiScsiLib/UefiScsiLib.c +++ b/MdePkg/Library/UefiScsiLib/UefiScsiLib.c @@ -1494,7 +1494,17 @@ ScsiRead10CommandEx ( goto ErrorExit; } - return ScsiIo->ExecuteScsiCommand (ScsiIo, CommandPacket, SelfEvent); + Status = ScsiIo->ExecuteScsiCommand (ScsiIo, CommandPacket, SelfEvent); + if (EFI_ERROR(Status)) { + // + // Since ScsiLibNotify() will not be signaled if ExecuteScsiCommand() + // returns with error, close the event here. + // + gBS->CloseEvent (SelfEvent); + goto ErrorExit; + } else { + return EFI_SUCCESS; + } ErrorExit: if (Context != NULL) { @@ -1668,7 +1678,17 @@ ScsiWrite10CommandEx ( goto ErrorExit; } - return ScsiIo->ExecuteScsiCommand (ScsiIo, CommandPacket, Event); + Status = ScsiIo->ExecuteScsiCommand (ScsiIo, CommandPacket, SelfEvent); + if (EFI_ERROR(Status)) { + // + // Since ScsiLibNotify() will not be signaled if ExecuteScsiCommand() + // returns with error, close the event here. + // + gBS->CloseEvent (SelfEvent); + goto ErrorExit; + } else { + return EFI_SUCCESS; + } ErrorExit: if (Context != NULL) { @@ -1842,7 +1862,17 @@ ScsiRead16CommandEx ( goto ErrorExit; } - return ScsiIo->ExecuteScsiCommand (ScsiIo, CommandPacket, Event); + Status = ScsiIo->ExecuteScsiCommand (ScsiIo, CommandPacket, SelfEvent); + if (EFI_ERROR(Status)) { + // + // Since ScsiLibNotify() will not be signaled if ExecuteScsiCommand() + // returns with error, close the event here. + // + gBS->CloseEvent (SelfEvent); + goto ErrorExit; + } else { + return EFI_SUCCESS; + } ErrorExit: if (Context != NULL) { @@ -2016,7 +2046,17 @@ ScsiWrite16CommandEx ( goto ErrorExit; } - return ScsiIo->ExecuteScsiCommand (ScsiIo, CommandPacket, Event); + Status = ScsiIo->ExecuteScsiCommand (ScsiIo, CommandPacket, SelfEvent); + if (EFI_ERROR(Status)) { + // + // Since ScsiLibNotify() will not be signaled if ExecuteScsiCommand() + // returns with error, close the event here. + // + gBS->CloseEvent (SelfEvent); + goto ErrorExit; + } else { + return EFI_SUCCESS; + } ErrorExit: if (Context != NULL) { -- cgit v1.2.3