From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 192.55.52.120, mailfrom: chasel.chiu@intel.com) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by groups.io with SMTP; Mon, 02 Sep 2019 06:48:12 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 02 Sep 2019 06:48:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,459,1559545200"; d="scan'208";a="198585873" Received: from pgsmsx114.gar.corp.intel.com ([10.108.55.203]) by fmsmga001.fm.intel.com with ESMTP; 02 Sep 2019 06:48:11 -0700 Received: from pgsmsx111.gar.corp.intel.com ([169.254.2.22]) by pgsmsx114.gar.corp.intel.com ([169.254.4.237]) with mapi id 14.03.0439.000; Mon, 2 Sep 2019 21:48:10 +0800 From: "Chiu, Chasel" To: "Zhang, Shenglei" , "devel@edk2.groups.io" CC: "Kubacki, Michael A" , "Desimone, Nathaniel L" , "Gao, Liming" Subject: Re: [PATCH 1/2] MinPlatformPkg/AcpiTables: Initialize variables before used Thread-Topic: [PATCH 1/2] MinPlatformPkg/AcpiTables: Initialize variables before used Thread-Index: AQHVYYo2GwLpe6xiOEe25s9w9IzB8acYZrDA Date: Mon, 2 Sep 2019 13:48:09 +0000 Message-ID: <3C3EFB470A303B4AB093197B6777CCEC5047E718@PGSMSX111.gar.corp.intel.com> References: <20190902123017.26220-1-shenglei.zhang@intel.com> <20190902123017.26220-2-shenglei.zhang@intel.com> In-Reply-To: <20190902123017.26220-2-shenglei.zhang@intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.2.0.6 dlp-reaction: no-action x-titus-metadata-40: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiMTYyOTAyYjMtNzQ5Yy00YmVkLTk3NzEtNjkwYjdhMWJmYmE0IiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiSUxCMklhZm1DZmQyRVowZWVaN25XMkx1TEVrbTUzUkFpZmxVNFNHUkE1MVFBTWY2KzNkcitVTWpRdHVZb3h5RSJ9 x-ctpclassification: CTP_NT x-originating-ip: [172.30.20.205] MIME-Version: 1.0 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Please extend copyright. With this update, Reviewed-by: Chasel Chiu > -----Original Message----- > From: Zhang, Shenglei > Sent: Monday, September 2, 2019 8:30 PM > To: devel@edk2.groups.io > Cc: Kubacki, Michael A ; Chiu, Chasel > ; Desimone, Nathaniel L > ; Gao, Liming > Subject: [PATCH 1/2] MinPlatformPkg/AcpiTables: Initialize variables befo= re > used >=20 > MadtStructs, NewMadtTable and MaxMadtStructCount are not initialized > before used or at the proper place. So assign values to them at the > beginning and change the logic when freeing MadtStructs and > NewMadtTable. >=20 > Cc: Michael Kubacki > Cc: Chasel Chiu > Cc: Nate DeSimone > Cc: Liming Gao > Signed-off-by: Shenglei Zhang > --- > .../Acpi/AcpiTables/AcpiPlatform.c | 19 +++++++++++-------- > 1 file changed, 11 insertions(+), 8 deletions(-) >=20 > diff --git a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c > b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c > index 5eb72792..85d1bd9a 100644 > --- a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c > +++ b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c > @@ -867,13 +867,15 @@ InstallMadtFromScratch ( > UINT32 > PcIoApicMask; > UINTN > PcIoApicIndex; >=20 > + MadtStructs =3D NULL; > + NewMadtTable =3D NULL; > + MaxMadtStructCount =3D 0; > + > DetectApicIdMap(); >=20 > // Call for Local APIC ID Reorder > SortCpuLocalApicInTable (); >=20 > - NewMadtTable =3D NULL; > - > MaxMadtStructCount =3D (UINT32) ( > MAX_CPU_NUM + // processor local APIC structures > MAX_CPU_NUM + // processor local x2APIC structures > @@ -1115,14 +1117,15 @@ Done: > // > // Free memory > // > - for (MadtStructsIndex =3D 0; MadtStructsIndex < MaxMadtStructCount; > MadtStructsIndex++) { > - if (MadtStructs[MadtStructsIndex] !=3D NULL) { > - FreePool (MadtStructs[MadtStructsIndex]); > + if (MadtStructs !=3D NULL){ > + for (MadtStructsIndex =3D 0; MadtStructsIndex < MaxMadtStructCount; > MadtStructsIndex++) { > + if (MadtStructs[MadtStructsIndex] !=3D NULL) { > + FreePool (MadtStructs[MadtStructsIndex]); > + } > } > + FreePool (MadtStructs); > } > - > - FreePool (MadtStructs); > - > + > if (NewMadtTable !=3D NULL) { > FreePool (NewMadtTable); > } > -- > 2.18.0.windows.1