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.43, mailfrom: nathaniel.l.desimone@intel.com) Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by groups.io with SMTP; Thu, 12 Sep 2019 11:36:02 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga105.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Sep 2019 11:36:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,498,1559545200"; d="scan'208";a="192506525" Received: from orsmsx108.amr.corp.intel.com ([10.22.240.6]) by FMSMGA003.fm.intel.com with ESMTP; 12 Sep 2019 11:36:01 -0700 Received: from orsmsx114.amr.corp.intel.com ([169.254.8.225]) by ORSMSX108.amr.corp.intel.com ([169.254.2.9]) with mapi id 14.03.0439.000; Thu, 12 Sep 2019 11:35:59 -0700 From: "Nate DeSimone" To: "devel@edk2.groups.io" , "Zhang, Shenglei" CC: "Kubacki, Michael A" , "Chiu, Chasel" , "Gao, Liming" Subject: Re: [edk2-devel] [PATCH v2 1/2] MinPlatformPkg/AcpiTables: Initialize variables before used Thread-Topic: [edk2-devel] [PATCH v2 1/2] MinPlatformPkg/AcpiTables: Initialize variables before used Thread-Index: AQHVaRodiJlWn/NBfEymZ4ckgEeMiKcoX37A Date: Thu, 12 Sep 2019 18:35:58 +0000 Message-ID: <02A34F284D1DA44BB705E61F7180EF0AAEEB43A6@ORSMSX114.amr.corp.intel.com> References: <20190912032720.38132-1-shenglei.zhang@intel.com> <20190912032720.38132-2-shenglei.zhang@intel.com> In-Reply-To: <20190912032720.38132-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: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiNjQ4Y2I5NzItNzZiMC00ZGQyLWE2NmItMGJhZmZiNmZkYmRiIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoidG1QSWNpSjAwUDlyMjgzMHpDaXBsQXlYTm5cL2RMVUUrUnFXS2F1bzllOVhLNHhHdzMxOWRxSXhmVFRvTzVjRlgifQ== x-ctpclassification: CTP_NT x-originating-ip: [10.22.254.140] MIME-Version: 1.0 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Nate DeSimone -----Original Message----- From: devel@edk2.groups.io On Behalf Of Zhang, Shen= glei Sent: Wednesday, September 11, 2019 8:27 PM To: devel@edk2.groups.io Cc: Kubacki, Michael A ; Chiu, Chasel ; Desimone, Nathaniel L ; G= ao, Liming Subject: [edk2-devel] [PATCH v2 1/2] MinPlatformPkg/AcpiTables: Initialize= variables before used MadtStructs, NewMadtTable and MaxMadtStructCount are not initialized befor= e used or at the proper place. So assign values to them at the beginning an= d change the logic when freeing MadtStructs and NewMadtTable. Cc: Michael Kubacki Cc: Chasel Chiu Cc: Nate DeSimone Cc: Liming Gao Signed-off-by: Shenglei Zhang --- .../Acpi/AcpiTables/AcpiPlatform.c | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c = b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c index 5eb72792..2cc55ee8 100644 --- a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c +++ b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c @@ -1,7 +1,7 @@ /** @file ACPI Platform Driver =20 -Copyright (c) 2017, Intel Corporation. All rights reserved.
+Copyright (c) 2017-2019, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ @@ -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; Mad= tStructsIndex++) { - if (MadtStructs[MadtStructsIndex] !=3D NULL) { - FreePool (MadtStructs[MadtStructsIndex]); + if (MadtStructs !=3D NULL){ + for (MadtStructsIndex =3D 0; MadtStructsIndex < MaxMadtStructCount; M= adtStructsIndex++) { + if (MadtStructs[MadtStructsIndex] !=3D NULL) { + FreePool (MadtStructs[MadtStructsIndex]); + } } + FreePool (MadtStructs); } - - FreePool (MadtStructs); - + if (NewMadtTable !=3D NULL) { FreePool (NewMadtTable); } -- 2.18.0.windows.1