From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-x235.google.com (mail-wr0-x235.google.com [IPv6:2a00:1450:400c:c0c::235]) (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 73A27802BB for ; Fri, 3 Mar 2017 13:23:20 -0800 (PST) Received: by mail-wr0-x235.google.com with SMTP id u108so81764941wrb.3 for ; Fri, 03 Mar 2017 13:23:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=l2up2++eJJ5T8lTauTTjRgLV89RTg1aTs2j1njRFIbE=; b=QpAWjSa17Gmjq4nVUVcdkYqsP7WeeRnRxXhWPuB9FlFVFb6v7oy0ro5UrP+r2bvvgK 2qEhBEip/ya8Rapk0JQghc6vys2y8qd/d6odzJSJ56IjPtcG8BRz/jdAryLsvVD8EL17 BAPGkGaPE157LojH4GmMMh8YPaBYbIw7ZGEDY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=l2up2++eJJ5T8lTauTTjRgLV89RTg1aTs2j1njRFIbE=; b=tY4szlPUNnMGh9D+7Ef8ztTysV9PT6viAyfGvnF1Jjzk4hc3Q6w2GCoYFYDRkr+OW2 Tb/QQcN7mzs5VtwJRbqt5AiQu9sTkcMP9ru77iI/Fw2wYsNsAimMe/IFPSW5ECwxk47V QavvplUM9OJTz/wnWI9Vu7VPsPpGco1ZzC3PA/uAkZBSpwTvG6iehbriFldWjonIZpNY 5RjDgGJ34/+yneQoSqhu9s5v8iuhraeMQ0Rt6PwhMkPVrtrr0MSDk3B/oNWskg0KIo2N 5xzTCykvGDi1wjgI8iZQKLxM3D2I4BQxgEMsa0n1o95JNYJSZIbcblnA9NoHDeckU9pz NI4A== X-Gm-Message-State: AMke39lbk4GHD3W9A+Q/5cjKmgqdCK7ta88VD6chsLs2ZW5Y3/9OCdUP8TEQQ5l4Z35WkziB X-Received: by 10.223.133.188 with SMTP id 57mr4486610wrt.161.1488576198904; Fri, 03 Mar 2017 13:23:18 -0800 (PST) Received: from bivouac.eciton.net (bivouac.eciton.net. [2a00:1098:0:86:1000:23:0:2]) by smtp.gmail.com with ESMTPSA id e16sm16686680wra.36.2017.03.03.13.23.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 03 Mar 2017 13:23:18 -0800 (PST) Date: Fri, 3 Mar 2017 21:23:16 +0000 From: Leif Lindholm To: Ard Biesheuvel Cc: edk2-devel@lists.01.org, terry.lee@hpe.com Message-ID: <20170303212316.GS16034@bivouac.eciton.net> References: <1488393273-27283-1-git-send-email-ard.biesheuvel@linaro.org> MIME-Version: 1.0 In-Reply-To: <1488393273-27283-1-git-send-email-ard.biesheuvel@linaro.org> User-Agent: Mutt/1.5.23 (2014-03-12) Subject: Re: [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: Fri, 03 Mar 2017 21:23:20 -0000 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Wed, Mar 01, 2017 at 06:34:33PM +0000, Ard Biesheuvel wrote: > 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 This looks good. I'll make one non-functional ecomment, and you can decide whether to incorporate it before pushing or not. Reviewed-by: Leif Lindholm > --- > > 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. I realise this comment is just being moved, but it's confusing. It refers to a state that is only visible if you're already aware of 2 or 3 facts not visible at this point. If I understand the situation correctly, the following would be a more helpful description: // If the console splitter driver is supported by the platform, then // *Interface is already initialized. If it is not, use the first // successfully connected device as the console. > + 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 >