From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.120; helo=mga04.intel.com; envelope-from=dandan.bi@intel.com; receiver=edk2-devel@lists.01.org Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id F2C1D2083797B for ; Wed, 9 May 2018 20:45:48 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 May 2018 20:45:48 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,383,1520924400"; d="scan'208";a="40068243" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga008.jf.intel.com with ESMTP; 09 May 2018 20:45:47 -0700 Received: from fmsmsx153.amr.corp.intel.com (10.18.125.6) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 9 May 2018 20:45:47 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX153.amr.corp.intel.com (10.18.125.6) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 9 May 2018 20:45:47 -0700 Received: from shsmsx102.ccr.corp.intel.com ([169.254.2.79]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.40]) with mapi id 14.03.0319.002; Thu, 10 May 2018 11:45:44 +0800 From: "Bi, Dandan" To: "Ni, Ruiyu" , Gary Lin CC: "edk2-devel@lists.01.org" , "Dong, Eric" , "Gao, Liming" Thread-Topic: [edk2] [patch v2] BaseTools/VfrCompile: Avoid using uninitialized pointer Thread-Index: AQHT51L1xAkqYixnkUGFN4IG8NZ446QmiFSAgAFCgYCAAIgLwA== Date: Thu, 10 May 2018 03:45:44 +0000 Message-ID: <3C0D5C461C9E904E8F62152F6274C0BB3BAD3D4C@shsmsx102.ccr.corp.intel.com> References: <20180509050211.76104-1-dandan.bi@intel.com> <20180509082009.uotkzgubbm2qtg2b@GaryWorkstation> <734D49CCEBEEF84792F5B80ED585239D5BC8DDCB@SHSMSX104.ccr.corp.intel.com> In-Reply-To: <734D49CCEBEEF84792F5B80ED585239D5BC8DDCB@SHSMSX104.ccr.corp.intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [patch v2] BaseTools/VfrCompile: Avoid using uninitialized pointer X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 May 2018 03:45:49 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Ray, Thanks for your suggestion. But we have committed this patch yesterday. :( I will pay more attention to the commit message in the future work. Thanks, Dandan -----Original Message----- From: Ni, Ruiyu=20 Sent: Thursday, May 10, 2018 11:34 AM To: Gary Lin ; Bi, Dandan Cc: edk2-devel@lists.01.org; Dong, Eric ; Gao, Liming = Subject: RE: [edk2] [patch v2] BaseTools/VfrCompile: Avoid using uninitiali= zed pointer Dandan, Can you describe the build failure met by Gary Lin in final commit message? The current commit message is not very clear about which issue it may fix. Thanks/Ray > -----Original Message----- > From: edk2-devel On Behalf Of Gary=20 > Lin > Sent: Wednesday, May 9, 2018 4:20 PM > To: Bi, Dandan > Cc: edk2-devel@lists.01.org; Dong, Eric ; Gao,=20 > Liming > Subject: Re: [edk2] [patch v2] BaseTools/VfrCompile: Avoid using=20 > uninitialized pointer >=20 > On Wed, May 09, 2018 at 01:02:11PM +0800, Dandan Bi wrote: > > V2: > > Add function _INIT_OPHDR_COND () for variable initialization. > > Make code logic more clean. > > > > Previously _CLEAR_SAVED_OPHDR () is used for variable=20 > > initialization, and we updated it to clean memory. > > But _CLEAR_SAVED_OPHDR () is still called for variable initialization. > > This will cause uninitialized pointer will be checked to free and=20 > > cause unexpected issue. > > > > This patch is to add new function for variable initialization and=20 > > keep _CLEAR_SAVED_OPHDR () to clean memory which is aligned with its=20 > > function name. > > > This patch fixes the build errors I had :) >=20 > Tested-by: Gary Lin >=20 > > Cc: Eric Dong > > Cc: Liming Gao > > Cc: Gary Lin > > Contributed-under: TianoCore Contribution Agreement 1.1 > > Signed-off-by: Dandan Bi > > --- > > BaseTools/Source/C/VfrCompile/VfrSyntax.g | 23 > > ++++++++++++++++++++--- > > 1 file changed, 20 insertions(+), 3 deletions(-) > > > > diff --git a/BaseTools/Source/C/VfrCompile/VfrSyntax.g > > b/BaseTools/Source/C/VfrCompile/VfrSyntax.g > > index 4b0a43606ea..84dd2c3ed3f 100644 > > --- a/BaseTools/Source/C/VfrCompile/VfrSyntax.g > > +++ b/BaseTools/Source/C/VfrCompile/VfrSyntax.g > > @@ -4084,11 +4084,19 @@ vfrStatementInvalidSaveRestoreDefaults : > > > > // > > // Root expression extension function called by other function. > > // > > vfrStatementExpression [UINT32 RootLevel, UINT32 ExpOpCount =3D 0] : > > - << if ($RootLevel =3D=3D 0) {mCIfrOpHdrIndex ++; if (mCIfrOpHdrIndex= =20 > > >=3D > > MAX_IFR_EXPRESSION_DEPTH) _PCATCH > (VFR_RETURN_INVALID_PARAMETER, 0, > > "The depth of expression exceeds the max supported level 8!");=20 > > _CLEAR_SAVED_OPHDR ();} >> > > + << > > + if ($RootLev= el =3D=3D 0) { > > + mCIfrOpHdr= Index ++; > > + if=20 > > + (mCIfrOpHdrIndex >=3D > MAX_IFR_EXPRESSION_DEPTH) { > > + =20 > > + _PCATCH > (VFR_RETURN_INVALID_PARAMETER, 0, "The depth of expression exceeds the=20 > max supported level 8!"); > > + } > > + _INIT_OPHD= R_COND (); > > + } > > + >> > > andTerm[$RootLevel, $ExpOpCount] > > ( > > L:OR andTerm[$RootLevel, $ExpOpCount] << $ExpOpCount+= +; > CIfrOr OObj(L->getLine()); >> > > )* > > << @@=20 > > -4988,10 > > +4996,11 @@ private: > > CIfrOpHeader * mCIfrOpHdr[MAX_IFR_EXPRESSION_DEPTH]; > > UINT32 mCIfrOpHdrLineNo[MAX_IFR_EXPRESSION_DEPTH]; > > UINT8 mCIfrOpHdrIndex; > > VOID _SAVE_OPHDR_COND (IN CIfrOpHeader &, IN BOOLEAN, > UINT32 LineNo =3D 0); > > VOID _CLEAR_SAVED_OPHDR (VOID); > > + VOID _INIT_OPHDR_COND (VOID); > > BOOLEAN _SET_SAVED_OPHDR_SCOPE (VOID); > > > > > > EFI_VARSTORE_INFO mCurrQestVarInfo; > > EFI_GUID *mOverrideClassGuid; > > @@ -5077,20 +5086,28 @@ EfiVfrParser::_SAVE_OPHDR_COND ( > > mCIfrOpHdr[mCIfrOpHdrIndex] =3D new CIfrOpHeader(OpHdr); > > mCIfrOpHdrLineNo[mCIfrOpHdrIndex] =3D LineNo; > > } > > } > > > > +VOID > > +EfiVfrParser::_INIT_OPHDR_COND ( > > + VOID > > + ) > > +{ > > + mCIfrOpHdr[mCIfrOpHdrIndex] =3D NULL; > > + mCIfrOpHdrLineNo[mCIfrOpHdrIndex] =3D 0; } > > + > > VOID > > EfiVfrParser::_CLEAR_SAVED_OPHDR ( > > VOID > > ) > > { > > if (mCIfrOpHdr[mCIfrOpHdrIndex] !=3D NULL) { > > delete mCIfrOpHdr[mCIfrOpHdrIndex]; > > - mCIfrOpHdr[mCIfrOpHdrIndex] =3D NULL; > > + mCIfrOpHdr[mCIfrOpHdrIndex] =3D NULL; > > } > > - mCIfrOpHdrLineNo[mCIfrOpHdrIndex] =3D 0; } > > > > BOOLEAN > > EfiVfrParser::_SET_SAVED_OPHDR_SCOPE ( > > VOID > > -- > > 2.14.3.windows.1 > > > > _______________________________________________ > > edk2-devel mailing list > > edk2-devel@lists.01.org > > https://lists.01.org/mailman/listinfo/edk2-devel > > > _______________________________________________ > edk2-devel mailing list > edk2-devel@lists.01.org > https://lists.01.org/mailman/listinfo/edk2-devel