Revision: 19469
          http://sourceforge.net/p/edk2/code/19469
Author:   hwu1225
Date:     2015-12-23 01:36:07 +0000 (Wed, 23 Dec 2015)
Log Message:
-----------
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 <[email protected]>
Reviewed-by: Feng Tian <[email protected]>

Revision Links:
--------------
    http://sourceforge.net/p/edk2/code/19448

Modified Paths:
--------------
    branches/UDK2015/MdePkg/Library/UefiScsiLib/UefiScsiLib.c

Modified: branches/UDK2015/MdePkg/Library/UefiScsiLib/UefiScsiLib.c
===================================================================
--- branches/UDK2015/MdePkg/Library/UefiScsiLib/UefiScsiLib.c   2015-12-23 
01:35:47 UTC (rev 19468)
+++ branches/UDK2015/MdePkg/Library/UefiScsiLib/UefiScsiLib.c   2015-12-23 
01:36:07 UTC (rev 19469)
@@ -1494,7 +1494,17 @@
     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 @@
     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 @@
     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 @@
     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) {


------------------------------------------------------------------------------
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to