From nobody Mon Apr 29 12:42:30 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+46668+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+46668+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1567427423; cv=none; d=zoho.com; s=zohoarc; b=kSPgkpfD6h4DB4GXay7sl3vbNxF3RsezOFKfnOhmHy9LwOvBsfbuaakL2VdANDRQP3512TyLBCPxyQ0MmbMf256xpbbTTnoQGPT4CEBS8v4XNwIMsE/7D15f3gPgXkxEjMLk6GZAeMcpgj6ljHCRPEjUDg5CW3QP8TTWP7Xwf3Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567427423; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=zwZSd/XvVb9AdUHqHUI0VtZieAFmOlMiM/ccryHop+g=; b=aCQ5RB1uNvSe/367c7pxGns/U010jSjcZv69Pn3fKkWrxtwP9XkeJqdTnr9yJGm+liakFvf1eohPjUuPrI9X+SCUkkpXYPpC7MDVJ5A9sE/gHaf5et0dobuMWM2RthW4/E9LnsjHq+qTbbcPxbihx1KjIZvqJZEKoVkLD/LXHKg= 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+46668+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 156742742382152.84893307111429; Mon, 2 Sep 2019 05:30:23 -0700 (PDT) Return-Path: X-Received: from mga17.intel.com (mga17.intel.com []) by groups.io with SMTP; Mon, 02 Sep 2019 05:30: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; 02 Sep 2019 05:30:22 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,459,1559545200"; d="scan'208";a="186989601" X-Received: from shenglei-dev.ccr.corp.intel.com ([10.239.158.52]) by orsmga006.jf.intel.com with ESMTP; 02 Sep 2019 05:30:21 -0700 From: "Zhang, Shenglei" To: devel@edk2.groups.io Cc: Michael Kubacki , Chasel Chiu , Nate DeSimone , Liming Gao Subject: [edk2-devel] [PATCH 1/2] MinPlatformPkg/AcpiTables: Initialize variables before used Date: Mon, 2 Sep 2019 20:30:16 +0800 Message-Id: <20190902123017.26220-2-shenglei.zhang@intel.com> In-Reply-To: <20190902123017.26220-1-shenglei.zhang@intel.com> References: <20190902123017.26220-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=1567427423; bh=kDOpIgKPTOZge+8CXaBJ3a9BsAKUBKabtMNBoPK9QOM=; h=Cc:Date:From:Reply-To:Subject:To; b=Ic05IVVY1ShQrsLQXdKzRaLLkeZqL8UpIhPkRibWojGJhbfRDUf0d9j06n5CsSnDA3L UpMkl0V1gBSrJoO75gOrcXP2T7zZHPmEB4pxGPLUxMkAIVEOXrDY/Mw1OpMNQ6FBrnSq3 9oJBqO4vMel7s/H7Xfd1zFV5H33IuU12pv0= 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 --- .../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); } --=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 (#46668): https://edk2.groups.io/g/devel/message/46668 Mute This Topic: https://groups.io/mt/33110578/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 Mon Apr 29 12:42:30 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+46669+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+46669+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1567427425; cv=none; d=zoho.com; s=zohoarc; b=mEDL+eZi2ylJkOUVbjEAZ3Ao/VskHLrfSlnRZciq9VF4BZATBZueAYHakZMh5L4bxRFo5fIzWxLPuDVxsTL9duzR5DxlIjpkNACoEQAmh0o4dC6Yf/FilLpetbLyTO6GVaXBC2WSY3Qdkp2q1O86w7DqtXTKufVj5MW0OpW0P8I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1567427425; h=Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=y3bZD9kKvEQ1qHFAiQLzgXUu0lAogEIeQlNKMccuz/o=; b=hHLUEBzrzE8sMbiUQN5yj2LrsrNSwyWXLPLfo045Bacavn0nTwxpt/4LMG7S/40rY+gDCkusJWsbpCDcs/CASe1QUJ0/c6YEIM4dfjhT0SVrUtaxMIbVVBGu0Zzk+aWP+oxY5ovJwAlK3zSsBAJLs09IMyx5UlXbr9DD1NUcDZo= 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+46669+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 1567427425569472.20799903805175; Mon, 2 Sep 2019 05:30:25 -0700 (PDT) Return-Path: X-Received: from mga17.intel.com (mga17.intel.com []) by groups.io with SMTP; Mon, 02 Sep 2019 05:30:24 -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; 02 Sep 2019 05:30:24 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.64,459,1559545200"; d="scan'208";a="186989613" X-Received: from shenglei-dev.ccr.corp.intel.com ([10.239.158.52]) by orsmga006.jf.intel.com with ESMTP; 02 Sep 2019 05:30:23 -0700 From: "Zhang, Shenglei" To: devel@edk2.groups.io Cc: Michael Kubacki , Chasel Chiu , Nate DeSimone , Liming Gao Subject: [edk2-devel] [PATCH 2/2] MinPlatformPkg/AcpiTables: Add error handling to SortCpuLocalApicInTable Date: Mon, 2 Sep 2019 20:30:17 +0800 Message-Id: <20190902123017.26220-3-shenglei.zhang@intel.com> In-Reply-To: <20190902123017.26220-1-shenglei.zhang@intel.com> References: <20190902123017.26220-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=1567427425; bh=KZCQo7h8+5p31W2pB1cWoLfFv0yrC413InxJ4Zn5ueI=; h=Cc:Date:From:Reply-To:Subject:To; b=nCvDZb4wjrpoOnckLwvOOp8fheRVNhLQDMayuSig+xJq0Z+w4YZNcKiFgEQAv2X4cEJ rZOxVIJ6hBIZsxDRjtWFkm8ecx6bepbolYygPKDyM2beP+sAVX90s9cQ2BYyb5kXise7K f8bNhA62LPbvdcR+LsGMbNpWz1fifqfesLg= 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 --- .../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 85d1bd9a..dc68dfaa 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 (#46669): https://edk2.groups.io/g/devel/message/46669 Mute This Topic: https://groups.io/mt/33110579/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-