public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Amit Kumar <amit.ak@samsung.com>
To: edk2-devel@lists.01.org
Cc: feng.tian@intel.com, akamit91@hotmail.com,
	Amit Kumar <amit.ak@samsung.com>
Subject: [PATCH V3] MdeModulePkg/DxeCore: Fixed Interface returned by CoreOpenProtocol
Date: Mon, 19 Jun 2017 17:53:51 +0530	[thread overview]
Message-ID: <7741fb0a1a1c12f94eb6756745bc39a9bcc58135.1497874973.git.amit.ak@samsung.com> (raw)
In-Reply-To: CGME20170619122254epcas5p49c12385e361c09d50eb4d0dfea71f41a@epcas5p4.samsung.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>
---
 MdeModulePkg/Core/Dxe/Hand/Handle.c | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/MdeModulePkg/Core/Dxe/Hand/Handle.c b/MdeModulePkg/Core/Dxe/Hand/Handle.c
index 1c25521..6de300f 100644
--- a/MdeModulePkg/Core/Dxe/Hand/Handle.c
+++ b/MdeModulePkg/Core/Dxe/Hand/Handle.c
@@ -1004,12 +1004,8 @@ CoreOpenProtocol (
   //
   // Check for invalid Interface
   //
-  if (Attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL) {
-    if (Interface == NULL) {
-      return EFI_INVALID_PARAMETER;
-    } else {
-      *Interface = NULL;
-    }
+  if ((Attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL) && (Interface == NULL)) {
+    return EFI_INVALID_PARAMETER;
   }
 
   //
@@ -1073,15 +1069,11 @@ CoreOpenProtocol (
   Prot = CoreGetProtocolInterface (UserHandle, Protocol);
   if (Prot == NULL) {
     Status = EFI_UNSUPPORTED;
+    // Return NULL Interface if Unsupported Protocol
+    *Interface = NULL;
     goto Done;
   }
 
-  //
-  // This is the protocol interface entry for this protocol
-  //
-  if (Attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL) {
-    *Interface = Prot->Interface;
-  }
   Status = EFI_SUCCESS;
 
   ByDriver        = FALSE;
@@ -1175,6 +1167,14 @@ CoreOpenProtocol (
   }
 
 Done:
+
+  //
+  // This is the protocol interface entry for this protocol.
+  // In case of any Error, Interface should not be updated as per spec.
+  //
+  if (!EFI_ERROR (Status) && Attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL) {
+    *Interface = Prot->Interface;
+  }
   //
   // Done. Release the database lock are return
   //
-- 
1.9.1



       reply	other threads:[~2017-06-19 12:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20170619122254epcas5p49c12385e361c09d50eb4d0dfea71f41a@epcas5p4.samsung.com>
2017-06-19 12:23 ` Amit Kumar [this message]
2017-06-19 14:41   ` [PATCH V3] MdeModulePkg/DxeCore: Fixed Interface returned by CoreOpenProtocol Gao, Liming
2017-06-20  9:58   ` Zeng, Star
     [not found]   ` <CGME20170619122254epcas5p49c12385e361c09d50eb4d0dfea71f41a@epcms5p3>
     [not found]     ` <20170622125419epcms5p3849260b8c26f233522e160c9a346933e@epcms5p3>
2017-06-22 13:07       ` Zeng, Star

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=7741fb0a1a1c12f94eb6756745bc39a9bcc58135.1497874973.git.amit.ak@samsung.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox