Revision: 19448
          http://sourceforge.net/p/edk2/code/19448
Author:   hwu1225
Date:     2015-12-22 13:55:59 +0000 (Tue, 22 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().

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <[email protected]>
Reviewed-by: Feng Tian <[email protected]>

Modified Paths:
--------------
    trunk/edk2/MdePkg/Library/UefiScsiLib/UefiScsiLib.c

Modified: trunk/edk2/MdePkg/Library/UefiScsiLib/UefiScsiLib.c
===================================================================
--- trunk/edk2/MdePkg/Library/UefiScsiLib/UefiScsiLib.c 2015-12-22 13:55:34 UTC 
(rev 19447)
+++ trunk/edk2/MdePkg/Library/UefiScsiLib/UefiScsiLib.c 2015-12-22 13:55:59 UTC 
(rev 19448)
@@ -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