public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] ArmPlatformPkg/PlatformIntelBdsLib: don't clobber ConSplitter handle
@ 2017-03-01 18:34 Ard Biesheuvel
  2017-03-03 21:23 ` Leif Lindholm
  0 siblings, 1 reply; 4+ messages in thread
From: Ard Biesheuvel @ 2017-03-01 18:34 UTC (permalink / raw)
  To: edk2-devel, leif.lindholm, terry.lee; +Cc: Ard Biesheuvel

The InitializeConsolePipe() routine takes care to only set its output
argument *Interface if it is not already set, to prevent overwriting
the ConSplitter interface pointer that may have already been assigned.

However, the associated OUT argument 'Handle' is clobbered by the
subsequent unnecessary LocateDevicePath() invocation, which should
similarly be made dependent on whether *Interface has been set
already.

Reported-by: "Lee, Terry Ping-Chung" <terry.lee@hpe.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---

Terry: does this work for you? Thanks.

 ArmPlatformPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c | 25 ++++++++++----------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/ArmPlatformPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c b/ArmPlatformPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c
index 885866854329..f8e04efea63d 100644
--- a/ArmPlatformPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c
+++ b/ArmPlatformPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c
@@ -148,12 +148,19 @@ InitializeConsolePipe (
 
     Status = BdsLibConnectDevicePath (DevicePath);
     if (!EFI_ERROR (Status)) {
-      //
-      // If BdsLibConnectDevicePath () succeeded, *Handle must have a non-NULL
-      // value. So ASSERT that this is the case.
-      //
-      gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &DevicePath, Handle);
-      ASSERT (*Handle != NULL);
+
+      // If the console splitter driver is not supported by the platform then
+      // use the first Device Path instance for the console interface.
+      if (*Interface == NULL) {
+        //
+        // If BdsLibConnectDevicePath () succeeded, *Handle must have a non-NULL
+        // value. So ASSERT that this is the case.
+        //
+        gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &DevicePath, Handle);
+        ASSERT (*Handle != NULL);
+
+        gBS->HandleProtocol (*Handle, Protocol, Interface);
+      }
     }
     DEBUG_CODE_BEGIN();
       if (EFI_ERROR(Status)) {
@@ -172,12 +179,6 @@ InitializeConsolePipe (
         }
       }
     DEBUG_CODE_END();
-
-    // If the console splitter driver is not supported by the platform then use the first Device Path
-    // instance for the console interface.
-    if (!EFI_ERROR(Status) && (*Interface == NULL)) {
-      Status = gBS->HandleProtocol (*Handle, Protocol, Interface);
-    }
   }
 
   // No Device Path has been defined for this console interface. We take the first protocol implementation
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-03-03 21:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-03-01 18:34 [PATCH] ArmPlatformPkg/PlatformIntelBdsLib: don't clobber ConSplitter handle Ard Biesheuvel
2017-03-03 21:23 ` Leif Lindholm
2017-03-03 21:32   ` Ard Biesheuvel
2017-03-03 21:37     ` Ard Biesheuvel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox