From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.groups.io with SMTP id smtpd.web10.5229.1574421730659425597 for ; Fri, 22 Nov 2019 03:22:10 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VE+TYRfr; spf=pass (domain: redhat.com, ip: 205.139.110.61, mailfrom: philmd@redhat.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1574421729; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kAzKckPPQISH1KcF/b3p8sJe1+qa5HfuJ5LoMcLb5XY=; b=VE+TYRfrp+7CGM6vsKxOOBvZ8lQfX2JVGFRGJbagMyAdzsgzwon76iJcDK4QZWgHlZWcRe TnWvgHXjer3Fw5fVSlMTnHC0JQqZEgc4mK963Aq/qdOEY7OM2VquSTtkKTa1tNDniVDlnk fsjQtlRa9PEzNeNmAugZsG/C4MRrZAs= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-4-esc5z0uVP3G64PGHjdUI-Q-1; Fri, 22 Nov 2019 06:22:07 -0500 Received: by mail-wm1-f70.google.com with SMTP id y14so3270183wmi.4 for ; Fri, 22 Nov 2019 03:22:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=ojrQ0+oziwakjsioZXWAbzVNQKAWu11wmoJX3d71Fqw=; b=OIaIVsTCjBFJQWTCRALzTOx7JvARX+BtUCM3tlBuq5qGLQpLM3WNxtkNqIMfuqqEKu 1zpBEvu16CXfnX62PCUCbaWPiEf6JY0EDvKmzLIJhxsLkEe0UqDav+4pBOcr9kj9Kec2 KDj8YMQ02CV+27YIgskqMiKm4cnCUgiYAkCBnle6nATmEdRixBuWYIEo+mGevrACbi3c rhe895DB6QJhc5SnxnDxyPgG5OCvRgRgR1LQlIj6h1Eo9WuioQqgG33KixLnVmZ6IVxO BYVqH4ttpLSBQCQlfTNLfUZAEX4TrqjqRQbNzGqar+3aQvgVNv5/fxmz1q3QjylUjIDT T4LA== X-Gm-Message-State: APjAAAWYf5i0T7fNp6dEt1JSdMuoyayjQL+aREbk/AZac9fxT3aZ1iBG scWP0jewPy4NA1FTdbBWlAoSaeNxIC3/XFzREaKk2ujFTWsi9X9GWNoPQVq3XZgEK2RJn3hsA+c q7oKytcnJkPTPdg== X-Received: by 2002:a7b:c181:: with SMTP id y1mr15578207wmi.16.1574421726192; Fri, 22 Nov 2019 03:22:06 -0800 (PST) X-Google-Smtp-Source: APXvYqy28O7ESm5B9B4Yti95Ldt/PPMidgaKOF0cundzTLIi60/3wzCLyk9Ps7mH56bLQKSFGpbJQw== X-Received: by 2002:a7b:c181:: with SMTP id y1mr15578175wmi.16.1574421725958; Fri, 22 Nov 2019 03:22:05 -0800 (PST) Return-Path: Received: from [192.168.1.35] (131.red-88-21-102.staticip.rima-tde.net. [88.21.102.131]) by smtp.gmail.com with ESMTPSA id j11sm6799854wrq.26.2019.11.22.03.22.04 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 22 Nov 2019 03:22:05 -0800 (PST) Subject: Re: [edk2-devel] [PATCH V1 1/1] MdeModulePkg/Variable: Initialize local variable To: "Kubacki, Michael A" , "devel@edk2.groups.io" Cc: "Gao, Liming" , "Kinney, Michael D" , "Wang, Jian J" , "Wu, Hao A" References: <20191121023256.24820-1-michael.a.kubacki@intel.com> From: =?UTF-8?B?UGhpbGlwcGUgTWF0aGlldS1EYXVkw6k=?= Message-ID: Date: Fri, 22 Nov 2019 12:22:02 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.1 MIME-Version: 1.0 In-Reply-To: X-MC-Unique: esc5z0uVP3G64PGHjdUI-Q-1 X-Mimecast-Spam-Score: 0 Content-Language: en-US Content-Type: text/plain; charset=WINDOWS-1252; format=flowed Content-Transfer-Encoding: quoted-printable On 11/21/19 8:22 PM, Kubacki, Michael A wrote: > Hi Philippe, >=20 > I will split the change into two patches. Thanks. >=20 > In the current implementation of VariableSmmRuntimeDxe.c there is > not an actual problem. The Status variable is set to EFI_NOT_FOUND > and RtPtrTrack is only used if Status is not set to an error code which > requires the RtPtrTrack variable to be set. Given that this is a > local variable, the initial value is undefined so I'd prefer to solve thi= s by > initializing the variable value. This will better accommodate future > changes to the function by having a reasonable default value. >=20 > Regarding your suggestion, the expected behavior is that > RtPtrTrack.CurrPtr is assigned in the for loop and the value is > used in the if block after the for block so jumping to the > Done label would not be appropriate. The variable would also > still be uninitialized. Yes you are right. >=20 > Thanks, > Michael >=20 >> -----Original Message----- >> From: Philippe Mathieu-Daud=E9 >> Sent: Thursday, November 21, 2019 8:16 AM >> To: devel@edk2.groups.io; Kubacki, Michael A >> >> Cc: Gao, Liming ; Kinney, Michael D >> ; Wang, Jian J ; Wu, >> Hao A >> Subject: Re: [edk2-devel] [PATCH V1 1/1] MdeModulePkg/Variable: Initiali= ze >> local variable >> >> Hi Michael, >> >> On 11/21/19 3:32 AM, Kubacki, Michael A wrote: >>> REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3D2364 >>> >>> Fixes a new build warning in VS2012 introduced in f8ff4cca7c. >>> >>> This patch initializes the local variable "Variable" in >>> VariableServiceGetNextVariableInternal () and the local variable >>> "RtPtrTrack" in FindVariableInRuntimeCache (). >>> This enusres the pointers in the structures are initialized >> >> Typo "this ensures" >> >>> in the case no variable stores exist in the list of variable stores. >>> >>> Cc: Liming Gao >>> Cc: Michael D Kinney >>> Cc: Jian J Wang >>> Cc: Hao A Wu >>> Signed-off-by: Michael Kubacki >>> --- >>> MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.c |= 2 >> ++ >>> >> MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDxe. >> c | 2 ++ >>> 2 files changed, 4 insertions(+) >>> >>> diff --git >>> a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.c >>> b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.c >>> index d458f1c608..f6d187543d 100644 >>> --- a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.c >>> +++ b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableParsing.c >>> @@ -551,6 +551,8 @@ VariableServiceGetNextVariableInternal ( >>> return EFI_INVALID_PARAMETER; >>> } >>> >>> + ZeroMem (&Variable, sizeof (Variable)); >>> + >> >> I agree with this change. >> >>> // Check if the variable exists in the given variable store list >>> for (StoreType =3D (VARIABLE_STORE_TYPE) 0; StoreType < >> VariableStoreTypeMax; StoreType++) { >>> if (VariableStoreList[StoreType] =3D=3D NULL) { diff --git >>> >> a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDx >> e.c >>> >> b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDx >> e.c >>> index d525998ae3..2cf0ed32ae 100644 >>> --- >>> >> a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDx >> e.c >>> +++ >> b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDx >> e >>> +++ .c >>> @@ -590,6 +590,8 @@ FindVariableInRuntimeCache ( >>> return EFI_INVALID_PARAMETER; >>> } >>> >>> + ZeroMem (&RtPtrTrack, sizeof (RtPtrTrack)); >>> + >>> // >>> // The UEFI specification restricts Runtime Services callers from = invoking >> the same or certain other Runtime Service >>> // functions prior to completion and return from a previous >>> Runtime Service call. These restrictions prevent >>> >> >> Here this seems overkill, what about: >> >> -- >8 -- >> --- >> a/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDx >> e.c >> +++ >> b/MdeModulePkg/Universal/Variable/RuntimeDxe/VariableSmmRuntimeDx >> e.c >> @@ -626,6 +626,10 @@ FindVariableInRuntimeCache ( >> } >> } >> >> + if (RtPtrTrack.CurrPtr) { >> + goto Done; >> + } >> + >> if (!EFI_ERROR (Status)) { >> // >> // Get data size >> >> --- >> >> Can you split this patch in 2? >> If so you can add to the 1st part: >> Reviewed-by: Philippe Mathieu-Daude >=20