]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Core/Dxe/Hand/Handle.c
MdeModulePkg/DxeCore: Fixed Interface returned by CoreOpenProtocol
[mirror_edk2.git] / MdeModulePkg / Core / Dxe / Hand / Handle.c
index 59b89148c8f0c51d6adb2ba7c615ffe8f4bf98b5..fe58b6c583c7cb4eb37f6b2379bc1ae4881ce9bf 100644 (file)
@@ -1006,12 +1006,8 @@ CoreOpenProtocol (
   //\r
   // Check for invalid Interface\r
   //\r
-  if (Attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL) {\r
-    if (Interface == NULL) {\r
-      return EFI_INVALID_PARAMETER;\r
-    } else {\r
-      *Interface = NULL;\r
-    }\r
+  if ((Attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL) && (Interface == NULL)) {\r
+    return EFI_INVALID_PARAMETER;\r
   }\r
 \r
   //\r
@@ -1075,15 +1071,13 @@ CoreOpenProtocol (
   Prot = CoreGetProtocolInterface (UserHandle, Protocol);\r
   if (Prot == NULL) {\r
     Status = EFI_UNSUPPORTED;\r
+    if (Attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL){\r
+      //Return NULL Interface if Unsupported Protocol\r
+      *Interface = NULL;\r
+    }\r
     goto Done;\r
   }\r
 \r
-  //\r
-  // This is the protocol interface entry for this protocol\r
-  //\r
-  if (Attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL) {\r
-    *Interface = Prot->Interface;\r
-  }\r
   Status = EFI_SUCCESS;\r
 \r
   ByDriver        = FALSE;\r
@@ -1177,6 +1171,14 @@ CoreOpenProtocol (
   }\r
 \r
 Done:\r
+\r
+  //\r
+  // This is the protocol interface entry for this protocol.\r
+  // In case of any Error, Interface should not be updated as per spec.\r
+  //\r
+  if (!EFI_ERROR (Status) && (Attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL)) {\r
+    *Interface = Prot->Interface;\r
+  }\r
   //\r
   // Done. Release the database lock are return\r
   //\r