From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-x231.google.com (mail-wr0-x231.google.com [IPv6:2a00:1450:400c:c0c::231]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 19940821B6 for ; Wed, 1 Mar 2017 10:34:41 -0800 (PST) Received: by mail-wr0-x231.google.com with SMTP id u48so36446704wrc.0 for ; Wed, 01 Mar 2017 10:34:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=K5iZPTtWkef16jajpj55UNXehMomc1gEvDz5AF2xwwg=; b=jBH/DjynSWV3iIa/b99lcevof+oe5lPHSsV7s5Lp6QRgct+ypAol+3ai+UxwTTeaI3 WCHqX1zdj96BanG7WpHBl8VFaBWqtxGVWTdx2JmMH3l5nznOig2cVWuMSb0wg7bYaMUr c1gaIHTt+oSsDdYI817OciQ91bzbnBNoncYJk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=K5iZPTtWkef16jajpj55UNXehMomc1gEvDz5AF2xwwg=; b=VvY0iTtVI8dSHTr/5pf9wwfTdPK/yYOd6vG/NogvHxtmFBv2KW0EsVYlQ37Lfv+O/K VC7Ds+S7qUesSGOHtgzfgfMypQB4FzvZGebm8H2BYO5SYGnqzGB/vUDipzLo58N0Dgib ScMeYdmWiNEoUe3ybXaTLad8702s56NHTEzT5juMUfm0R+FKLWx/bwuEXRMJb1Droteo Sm6NCB7aLyc/oGzE47TCXTQECcKHsBUoIxPvk3VuyhtWXXlJxetlF7EQSQMbFmrQMKVt fFvxL38NSN64odRS1FMeBmEjRHhwDYZqSnPZmAi9R81P4A77aMc6QhmQ2ewS83BM4hNK U5KQ== X-Gm-Message-State: AMke39m00KrW4SgAmOEwOVA9tyo95I25qPwVGfBNPxb8tp6TYsbSQIK09snyySKe4/gupVOw X-Received: by 10.223.132.37 with SMTP id 34mr8114333wrf.45.1488393279463; Wed, 01 Mar 2017 10:34:39 -0800 (PST) Received: from localhost.localdomain ([105.147.1.203]) by smtp.gmail.com with ESMTPSA id 10sm7637694wrw.13.2017.03.01.10.34.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 01 Mar 2017 10:34:38 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, terry.lee@hpe.com Cc: Ard Biesheuvel Date: Wed, 1 Mar 2017 18:34:33 +0000 Message-Id: <1488393273-27283-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 Subject: [PATCH] ArmPlatformPkg/PlatformIntelBdsLib: don't clobber ConSplitter handle X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 01 Mar 2017 18:34:41 -0000 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 --- 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