From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: intel.com, ip: 134.134.136.24, mailfrom: nathaniel.l.desimone@intel.com) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by groups.io with SMTP; Tue, 10 Sep 2019 15:28:09 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 10 Sep 2019 15:28:08 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,490,1559545200"; d="scan'208";a="178825193" Received: from orsmsx107.amr.corp.intel.com ([10.22.240.5]) by orsmga008.jf.intel.com with ESMTP; 10 Sep 2019 15:28:08 -0700 Received: from orsmsx153.amr.corp.intel.com (10.22.226.247) by ORSMSX107.amr.corp.intel.com (10.22.240.5) with Microsoft SMTP Server (TLS) id 14.3.439.0; Tue, 10 Sep 2019 15:28:07 -0700 Received: from orsmsx114.amr.corp.intel.com ([169.254.8.225]) by ORSMSX153.amr.corp.intel.com ([169.254.12.237]) with mapi id 14.03.0439.000; Tue, 10 Sep 2019 15:28:07 -0700 From: "Nate DeSimone" To: "Zhang, Shenglei" , "devel@edk2.groups.io" CC: "Kubacki, Michael A" , "Chiu, Chasel" , "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: AQHVYYo0QOY751gABkCe3jZSSjSowqclisFA Date: Tue, 10 Sep 2019 22:28:07 +0000 Message-ID: <02A34F284D1DA44BB705E61F7180EF0AAEEA7E94@ORSMSX114.amr.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: eyJDYXRlZ29yeUxhYmVscyI6IiIsIk1ldGFkYXRhIjp7Im5zIjoiaHR0cDpcL1wvd3d3LnRpdHVzLmNvbVwvbnNcL0ludGVsMyIsImlkIjoiZGNmMWY4MGItZTIxMi00NDU5LThiYWMtOGRhYjc3Nzk5ODUyIiwicHJvcHMiOlt7Im4iOiJDVFBDbGFzc2lmaWNhdGlvbiIsInZhbHMiOlt7InZhbHVlIjoiQ1RQX05UIn1dfV19LCJTdWJqZWN0TGFiZWxzIjpbXSwiVE1DVmVyc2lvbiI6IjE3LjEwLjE4MDQuNDkiLCJUcnVzdGVkTGFiZWxIYXNoIjoiSXZpN21zUHdCSjc4VFk3MVFwWW41NVpPMnBkdm1CZUdUM2JTRjdVdVFEYjFFT3c4WFhRTE5ZZDExdXROQjExaiJ9 x-ctpclassification: CTP_NT x-originating-ip: [10.22.254.138] MIME-Version: 1.0 Return-Path: nathaniel.l.desimone@intel.com Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Shenglei, Please send a second patch series with the copyrights updated. Thanks, Nate -----Original Message----- From: Zhang, Shenglei=20 Sent: Monday, September 2, 2019 5:30 AM To: devel@edk2.groups.io Cc: Kubacki, Michael A ; Chiu, Chasel ; Desimone, Nathaniel L ; Ga= o, Liming Subject: [PATCH 1/2] MinPlatformPkg/AcpiTables: Initialize variables before= used 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. 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(-) 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; Madt= StructsIndex++) { - if (MadtStructs[MadtStructsIndex] !=3D NULL) { - FreePool (MadtStructs[MadtStructsIndex]); + if (MadtStructs !=3D NULL){ + for (MadtStructsIndex =3D 0; MadtStructsIndex < MaxMadtStructCount; Ma= dtStructsIndex++) { + if (MadtStructs[MadtStructsIndex] !=3D NULL) { + FreePool (MadtStructs[MadtStructsIndex]); + } } + FreePool (MadtStructs); } - - FreePool (MadtStructs); - + =20 if (NewMadtTable !=3D NULL) { FreePool (NewMadtTable); } -- 2.18.0.windows.1