From 3858b4a1ff09d3243fea8d07bd135478237cb8f7 Mon Sep 17 00:00:00 2001 From: Ard Biesheuvel Date: Wed, 1 Mar 2017 18:34:33 +0000 Subject: [PATCH] ArmPlatformPkg/PlatformIntelBdsLib: don't clobber ConSplitter handle 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" Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- .../PlatformIntelBdsLib/IntelBdsPlatform.c | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/ArmPlatformPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c b/ArmPlatformPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c index 8858668543..5632b5da75 100644 --- a/ArmPlatformPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c +++ b/ArmPlatformPkg/Library/PlatformIntelBdsLib/IntelBdsPlatform.c @@ -148,12 +148,23 @@ 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. + // We connect all supplied console device paths, but only return the first + // one that connects successfully via *Handle/*Interface. Note that this + // may imply that *Handle/*Interface are not updated at all if they have + // been connected already, e.g., by the console splitter driver. // - gBS->LocateDevicePath (&gEfiDevicePathProtocolGuid, &DevicePath, Handle); - ASSERT (*Handle != NULL); + 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 +183,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