From nobody Thu Apr 25 07:39:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+47163+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+47163+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1568258892; cv=none; d=zoho.com; s=zohoarc; b=VSazjgRTAN1FFIb6pvoJ555jVscD6BaLz+wUTpCTH1blxzBJnG3IHW18DKPz7gazvMFrQqKsVcwNtHSm1If74HBPcRUI9e11oybHIwvohZq2vn+o9+YVwb4syPBk8fKdjHlrb1GasY0HwSGkQ6qGDKIlovu/Tb+V+nwYaxktq8k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568258892; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=wF9XD22d54LlkGyVV3SgulYk5kGio/44cnlEgtEE64A=; b=KWwt35YA93/BruEeBrvZF4FASM2ot/pGo9jp/UdmInQzqk82T1v7N2J/MA1kqsRdvd0dhBLqOX0l6WxLS5WZ5ir8l5C9SvSq7iFKMtdsk2WIzFT3pqzYU90Idm1nNbLT21FrLozVcomrHLUDfAfWpSBj8CO28Cd+2XIQ9TS/R0A= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+47163+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1568258892845226.13552057447623; Wed, 11 Sep 2019 20:28:12 -0700 (PDT) Return-Path: X-Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by groups.io with SMTP; Wed, 11 Sep 2019 20:28:11 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Sep 2019 20:28:11 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,492,1559545200"; d="scan'208";a="189861803" X-Received: from shenglei-dev.ccr.corp.intel.com ([10.239.158.52]) by orsmga006.jf.intel.com with ESMTP; 11 Sep 2019 20:28:09 -0700 From: "Zhang, Shenglei" To: devel@edk2.groups.io Cc: Michael Kubacki , Chasel Chiu , Nate DeSimone , Liming Gao Subject: [edk2-devel] [PATCH v2 1/2] MinPlatformPkg/AcpiTables: Initialize variables before used Date: Thu, 12 Sep 2019 11:27:18 +0800 Message-Id: <20190912032720.38132-2-shenglei.zhang@intel.com> In-Reply-To: <20190912032720.38132-1-shenglei.zhang@intel.com> References: <20190912032720.38132-1-shenglei.zhang@intel.com> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,shenglei.zhang@intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1568258892; bh=kfetieaESQog0am2XLq07pTgSzasT3JNDWtXh0E+f5c=; h=Cc:Date:From:Reply-To:Subject:To; b=sEki5hXJ5jo8AaqJnrsfPbcRmLkuQI+yT5hYffgwGNW9tdlMLEfQ+yl5jVDffUJAGJm 8emPBy8jOfOGN6Yzkko1qrxvOOniHx8iiK23hQX8OyUPVRxu6GIMcDmCqm0bU+UiK3SaY 4DNZe7HQmGuFxEIF65+6ke/FgfyPBWfsF2M= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Chasel Chiu Reviewed-by: Michael Kubacki Reviewed-by: Nate DeSimone --- .../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; 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); } --=20 2.18.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#47163): https://edk2.groups.io/g/devel/message/47163 Mute This Topic: https://groups.io/mt/34111552/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Thu Apr 25 07:39:00 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+47164+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+47164+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1568258903; cv=none; d=zoho.com; s=zohoarc; b=Y+Dk2Y2WbV3gezZjHL8gPilAKa16NTpnPz79JLkrOFBJAH0rN7SwgEC7sDPpaGcPeg02E9Sjl8jAtVPfcIuOhFTFfPcBRQp536q1JZfwMd3lOULWoolqa96UZujJIpMf2wTVA3sE0IOIaoJzp96hybllt/nRo8j8XjTzlickOv0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568258903; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=BVCDdzYIfv/jVf73fu/cgbowrTpqENpH16sejyHXi7o=; b=fqOQofR+FfdtfsTJI6o6iT6lpY1enOP7iYkHzm64pu/Mx6W2r1hlF1leKKLZlapExMKXzzhMeB9c6uhchHPFkXyH9J61pRJIoQWlIVwoQOn43vBm400R5Vku+wIVQyGeAkM/uhtJxP/oXWAa4KohlQWeCrx/Gd3/yi8QHR5zTmc= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+47164+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1568258903402201.3038663531779; Wed, 11 Sep 2019 20:28:23 -0700 (PDT) Return-Path: X-Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by groups.io with SMTP; Wed, 11 Sep 2019 20:28:22 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Sep 2019 20:28:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,492,1559545200"; d="scan'208";a="189861844" X-Received: from shenglei-dev.ccr.corp.intel.com ([10.239.158.52]) by orsmga006.jf.intel.com with ESMTP; 11 Sep 2019 20:28:20 -0700 From: "Zhang, Shenglei" To: devel@edk2.groups.io Cc: Michael Kubacki , Chasel Chiu , Nate DeSimone , Liming Gao Subject: [edk2-devel] [PATCH v2 2/2] MinPlatformPkg/AcpiTables: Add error handling to SortCpuLocalApicInTable Date: Thu, 12 Sep 2019 11:27:20 +0800 Message-Id: <20190912032720.38132-4-shenglei.zhang@intel.com> In-Reply-To: <20190912032720.38132-1-shenglei.zhang@intel.com> References: <20190912032720.38132-1-shenglei.zhang@intel.com> Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,shenglei.zhang@intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1568258903; bh=XDtwwzdDRQK4C5q+8TrNAHEw9bShWKdmQM2bhpZlwkk=; h=Cc:Date:From:Reply-To:Subject:To; b=p28oAco4bx+oNWODFvV6Lykg4UYjv3gkKdPk+WdF9Rj0zPIBV/fvlZ9NtkNB/41M0ip JeKQqU5iHrpf9wRDy0AKZSQE7gZ3U5Q4XroXY/JJJJx8iOjfBXfIRonWUxrnj/qaSXNuZ AcGRh7MnSYy1YlrjSzaRuh3IglIAkKkjKt4= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Change ASSERT_EFI_ERROR to return value when the "if" statement is true. As a result, when SortCpuLocalApicInTable is called, error handling is needed. So add "if" statement to judge the returned Status from SortCpuLocalApicInTable () in function InstallMadtFromScratch(). Cc: Michael Kubacki Cc: Chasel Chiu Cc: Nate DeSimone Cc: Liming Gao Signed-off-by: Shenglei Zhang Reviewed-by: Chasel Chiu Reviewed-by: Michael Kubacki Reviewed-by: Nate DeSimone --- .../Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c b= /Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c index 2cc55ee8..ae25d753 100644 --- a/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c +++ b/Platform/Intel/MinPlatformPkg/Acpi/AcpiTables/AcpiPlatform.c @@ -354,7 +354,7 @@ SortCpuLocalApicInTable ( =20 if(MAX_CPU_NUM <=3D Index) { DEBUG ((EFI_D_ERROR, "Asserting the SortCpuLocalApicInTable Index = Bufferflow\n")); - ASSERT_EFI_ERROR(EFI_INVALID_PARAMETER); + return EFI_INVALID_PARAMETER; } =20 TempVal =3D mCpuApicIdOrderTable[Index].ApicId; @@ -874,7 +874,11 @@ InstallMadtFromScratch ( DetectApicIdMap(); =20 // Call for Local APIC ID Reorder - SortCpuLocalApicInTable (); + Status =3D SortCpuLocalApicInTable (); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "SortCpuLocalApicInTable failed: %r\n", Status)); + goto Done; + } =20 MaxMadtStructCount =3D (UINT32) ( MAX_CPU_NUM + // processor local APIC structures --=20 2.18.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#47164): https://edk2.groups.io/g/devel/message/47164 Mute This Topic: https://groups.io/mt/34111553/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-