From nobody Mon Sep 16 19:41:33 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) client-ip=66.175.222.108; envelope-from=bounce+27952+101030+1787277+3901457@groups.io; helo=mail02.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101030+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=linux.microsoft.com ARC-Seal: i=1; a=rsa-sha256; t=1678473946; cv=none; d=zohomail.com; s=zohoarc; b=RoJARjspcJo3NegP8MMDDxFuKwW78N9XMei6Hg5ZwARTLDyb4PT2Ugmgyk11PCGajJiwln9bzoNv580C4MGISYrSY3TFeYBy1qE3kjknkzeDKCsmeE9Qp22BaS3bb4L7n45JOM+GoT16z/if1Q7+UDcrYqR3rV8ev66PrEAylsI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678473946; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Id:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To; bh=qKXp8LqVBpvR6d/H7sHajMiFtRrx0VjYZWFq8uJ30Fw=; b=A6Tq8QiZPWTIXZfTe6Ez54Qr+ahvd9IrjilwNlskufArC4LBWXZvMd583bH9iwIR8VuXO9GvM6WS/ASV1fbNJhm1iPemelh98CJQOsR049DLa/4AhYIG/WF/ONsq65giVXZ8nXoyMt+waaqIGhju2CE+e6zTPO6kqe+AmPWUJio= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of groups.io designates 66.175.222.108 as permitted sender) smtp.mailfrom=bounce+27952+101030+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) Received: from mail02.groups.io (mail02.groups.io [66.175.222.108]) by mx.zohomail.com with SMTPS id 167847394666511.289013568812948; Fri, 10 Mar 2023 10:45:46 -0800 (PST) Return-Path: X-Received: by 127.0.0.2 with SMTP id 32cnYY1788612x2ENGFP4TnB; Fri, 10 Mar 2023 10:45:46 -0800 X-Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mx.groups.io with SMTP id smtpd.web11.27871.1678473945770048012 for ; Fri, 10 Mar 2023 10:45:45 -0800 X-Received: from localhost.localdomain (unknown [47.201.8.94]) by linux.microsoft.com (Postfix) with ESMTPSA id A3B6220C14D5; Fri, 10 Mar 2023 10:45:44 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com A3B6220C14D5 From: "Michael Kubacki" To: devel@edk2.groups.io Cc: Eric Dong , Erich McMillan , Michael D Kinney , Michael Kubacki , Rahul Kumar , Ray Ni Subject: [edk2-devel] [PATCH v4 10/12] UefiCpuPkg: Fix conditionally uninitialized variables Date: Fri, 10 Mar 2023 13:42:36 -0500 Message-Id: <20230310184238.2999-11-mikuback@linux.microsoft.com> In-Reply-To: <20230310184238.2999-1-mikuback@linux.microsoft.com> References: <20230310184238.2999-1-mikuback@linux.microsoft.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: List-Subscribe: List-Help: 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,mikuback@linux.microsoft.com X-Gm-Message-State: aAAdyfw3jB2OoICOKsL1cohmx1787277AA= Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1678473946; bh=ovTgbP/7iSogTpDVcq0k8KR8/d/Uf6mmbjwMkE9DukE=; h=Cc:Date:From:Reply-To:Subject:To; b=IGP1UPc++7RoV+gmwXAotje2LelWpQSVgBqK2ELhsEBa8S41mLVy5nxtAaCOSHl72bc ZxjUWOzDtiUicHB2aYdAq+rdqpgU71gLRbKCmUBhIePVjvdfTgmXBX8o4D9T0YrOzpnXW lWK/2aLpLXWD09TUXOujuw7vbe9WGBXTCXA= X-ZohoMail-DKIM: pass (identity @groups.io) X-ZM-MESSAGEID: 1678473948191100002 Content-Type: text/plain; charset="utf-8" From: Michael Kubacki Fixes CodeQL alerts for CWE-457: https://cwe.mitre.org/data/definitions/457.html Cc: Eric Dong Cc: Erich McMillan Cc: Michael D Kinney Cc: Michael Kubacki Cc: Rahul Kumar Cc: Ray Ni Co-authored-by: Erich McMillan Signed-off-by: Michael Kubacki --- UefiCpuPkg/CpuMpPei/CpuBist.c | 8 +++++++- UefiCpuPkg/CpuMpPei/CpuMpPei.c | 8 +++++++- UefiCpuPkg/CpuMpPei/CpuPaging.c | 9 ++++++++- 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/UefiCpuPkg/CpuMpPei/CpuBist.c b/UefiCpuPkg/CpuMpPei/CpuBist.c index 7dc93cd784d4..122808139b87 100644 --- a/UefiCpuPkg/CpuMpPei/CpuBist.c +++ b/UefiCpuPkg/CpuMpPei/CpuBist.c @@ -175,7 +175,13 @@ CollectBistDataFromPpi ( EFI_SEC_PLATFORM_INFORMATION_RECORD2 *PlatformInformationRecord2; EFI_SEC_PLATFORM_INFORMATION_CPU *CpuInstanceInHob; =20 - MpInitLibGetNumberOfProcessors (&NumberOfProcessors, &NumberOfEnabledPro= cessors); + Status =3D MpInitLibGetNumberOfProcessors (&NumberOfProcessors, &NumberO= fEnabledProcessors); + ASSERT_EFI_ERROR (Status); + + if (EFI_ERROR (Status)) { + NumberOfProcessors =3D 1u; + NumberOfEnabledProcessors =3D 1u; + } =20 BistInformationSize =3D sizeof (EFI_SEC_PLATFORM_INFORMATION_RECORD2) + sizeof (EFI_SEC_PLATFORM_INFORMATION_CPU) * Number= OfProcessors; diff --git a/UefiCpuPkg/CpuMpPei/CpuMpPei.c b/UefiCpuPkg/CpuMpPei/CpuMpPei.c index e7f1fe9f426c..a84304273168 100644 --- a/UefiCpuPkg/CpuMpPei/CpuMpPei.c +++ b/UefiCpuPkg/CpuMpPei/CpuMpPei.c @@ -473,7 +473,13 @@ InitializeMpExceptionStackSwitchHandlers ( return; } =20 - MpInitLibGetNumberOfProcessors (&NumberOfProcessors, NULL); + Status =3D MpInitLibGetNumberOfProcessors (&NumberOfProcessors, NULL); + ASSERT_EFI_ERROR (Status); + + if (EFI_ERROR (Status)) { + NumberOfProcessors =3D 1u; + } + SwitchStackData =3D AllocatePages (EFI_SIZE_TO_PAGES (NumberOfProcessors= * sizeof (EXCEPTION_STACK_SWITCH_CONTEXT))); ASSERT (SwitchStackData !=3D NULL); ZeroMem (SwitchStackData, NumberOfProcessors * sizeof (EXCEPTION_STACK_S= WITCH_CONTEXT)); diff --git a/UefiCpuPkg/CpuMpPei/CpuPaging.c b/UefiCpuPkg/CpuMpPei/CpuPagin= g.c index 135422225340..1322fcb77f28 100644 --- a/UefiCpuPkg/CpuMpPei/CpuPaging.c +++ b/UefiCpuPkg/CpuMpPei/CpuPaging.c @@ -538,6 +538,7 @@ SetupStackGuardPage ( UINTN NumberOfProcessors; UINTN Bsp; UINTN Index; + EFI_STATUS Status; =20 // // One extra page at the bottom of the stack is needed for Guard page. @@ -547,7 +548,13 @@ SetupStackGuardPage ( ASSERT (FALSE); } =20 - MpInitLibGetNumberOfProcessors (&NumberOfProcessors, NULL); + Status =3D MpInitLibGetNumberOfProcessors (&NumberOfProcessors, NULL); + ASSERT_EFI_ERROR (Status); + + if (EFI_ERROR (Status)) { + NumberOfProcessors =3D 1u; + } + MpInitLibWhoAmI (&Bsp); for (Index =3D 0; Index < NumberOfProcessors; ++Index) { StackBase =3D 0; --=20 2.39.2.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 (#101030): https://edk2.groups.io/g/devel/message/101030 Mute This Topic: https://groups.io/mt/97526805/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-