]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/DxeCore: Fixed Interface returned by CoreOpenProtocol
authorAmit Kumar <amit.ak@samsung.com>
Fri, 23 Jun 2017 10:09:47 +0000 (18:09 +0800)
committerStar Zeng <star.zeng@intel.com>
Mon, 26 Jun 2017 02:45:33 +0000 (10:45 +0800)
Change since v3:
1) Fixed issue when Attributes = EFI_OPEN_PROTOCOL_TEST_PROTOCOL
and Inteface = NULL case. [Reported by:star.zeng at intel.com]

Change Since v2:
1) Modified to use EFI_ERROR to get status code

Change since v1:
1) Fixed typo protocal to protocol
2) Fixed coding style

Modified source code to update Interface as per spec.
1) In case of Protocol is un-supported, interface should be returned NULL.
2) In case of any error, interface should not be modified.
3) In case of Test Protocol, interface is optional.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Amit Kumar <amit.ak@samsung.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
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