From patchwork Wed Mar 1 18:34:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 94734 Delivered-To: patch@linaro.org Received: by 10.140.20.113 with SMTP id 104csp1936593qgi; Wed, 1 Mar 2017 10:34:43 -0800 (PST) X-Received: by 10.99.193.17 with SMTP id w17mr10425279pgf.124.1488393283009; Wed, 01 Mar 2017 10:34:43 -0800 (PST) Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id s65si5277142pfa.163.2017.03.01.10.34.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 01 Mar 2017 10:34:42 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 6522D821CF; Wed, 1 Mar 2017 10:34:42 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org 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 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: [edk2] [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: , Cc: Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" 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(-) -- 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Leif Lindholm 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